zoukankan      html  css  js  c++  java
  • SPquery

    Guid guid = new Guid("{8238B046-EC5F-46B6-8E18-028F77EC2620}");
                SPSite Asite = new SPSite("http://mosslt/");
                SPList list = Asite.RootWeb.Lists[guid];

                SPQuery query = new SPQuery();
               query.Query = @"
                                   <OrderBy>
                                        <FieldRef Name=ID' />
                                   </OrderBy>

                                   <Where>
                                        <Gt>
                                             <FieldRef Name='ID' />
                                             <Value Type='Counter'>0</Value>
                                        </Gt>
                                   </Where>"; //顺序按ID排,条件为ID大于0

                query.ViewFields = @"            
                                      <FieldRef Name='LinkTitle' />
                                      <FieldRef Name='htchange' />
                                      <FieldRef Name='htinfo' />";//要显示在前的三字段,后而会自动回上ID,Created


                this.GridView1.DataSource =list.GetItems(query).GetDataTable();
                this.GridView1.DataBind();

    字段及其它信息可以用Stramit Caml Viewer 2007 查看

    如:

    using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
    {
        SPList oList = oWebsiteRoot.Lists["List_Name"];

        SPQuery oQuery = new SPQuery();
        oQuery.ViewFields = "<FieldRef Name='Field1'/>" +
            "<FieldRef Name='Field2'/>";
        oQuery.Query = "<Where><Geq><FieldRef Name='Field2'/>" +
            "<Value Type='Number'>1000</Value></Geq></Where>";
        SPListItemCollection collListItems = oList.GetItems(oQuery);

        foreach (SPListItem oListItem in collListItems)
        {
            Response.Write(SPEncode.HtmlEncode(oListItem.Xml) + "<BR>");
        }
    }

    用法

    using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["Site_Name"])
    {
        SPList oList = oWebsite.Lists["List_Name"];

        SPQuery oQuery = new SPQuery();

        oQuery.ViewXml = "<View><Query><OrderBy><FieldRef Name='ID'/>" +
            "</OrderBy><Where><Or><Geq><FieldRef Name='Field1'/>" +
            "<Value Type='Number'>1500</Value></Geq><Leq>" +
            "<FieldRef Name='Field2'/><Value Type='Number'>500</Value>" +
            "</Leq></Or></Where></Query><ViewFields>" +
            "<FieldRef Name='Title'/>" +
            "<FieldRef Name='Field1'/><FieldRef Name='Field2'/>" +
            "<FieldRef Name='Field3'/><FieldRef Name='Field4'/>" +
            "</ViewFields><RowLimit>100</RowLimit></View>";
        SPListItemCollection collListItemsAvailable = oList.GetItems(oQuery);

        foreach (SPListItem oListItemAvailable in collListItemsAvailable)
        {
            Response.Write(SPEncode.HtmlEncode(oListItemAvailable.Xml) +
              "<BR>");
        }
    }

  • 相关阅读:
    ArcGIS for Android示例解析之高亮要素-----HighlightFeatures
    ArcGIS Runtime for Android开发教程V2.0(8)基础篇-----地图事件
    ArcGIS for Android示例解析之空间查询-----QueryTask
    ArcGIS for Android地图控件的5大常见操作
    ArcGIS Runtime for Android开发教程V2.0(4)基础篇---MapView
    ArcGIS for Android 中MapView的地图背景设置
    使用Arcglobe 10与3dmax建立三维城市
    使用PowerDesigner建立数据库模型
    一步一步学Remoting系列文章
    App集成支付宝
  • 原文地址:https://www.cnblogs.com/IsNull/p/1724802.html
Copyright © 2011-2022 走看看