简体   繁体   English

无法使用CAML查询获取Sharepoint列表数据

[英]Not able to fetch Sharepoint List data using CAML query

I am trying to fetch data from SP list using the CAML query listed below. 我正在尝试使用下面列出的CAML查询从SP列表中获取数据。

CAML Query CAML查询

oQuery.Query = "<Where><Eq><FieldRef Name='" 
    + jTitleMappingList.Fields["SET Area"].InternalName + "'/>"
    + "<Value Type='LOOKUP'>" + ddlSubsite.SelectedValue
    + "</Value></Eq></Where>";

Error Message Faced: 遇到错误消息:

{Microsoft.SharePoint.SPException: One or more field types are not installed properly. {Microsoft.SharePoint.SPException:一种或多种字段类型未正确安装。 Go to the list settings page to delete these fields. 转到列表设置页面以删除这些字段。 ---> System.Runtime.InteropServices.COMException (0x81020014): One or more field types are not installed properly. ---> System.Runtime.InteropServices.COMException(0x81020014):一种或多种字段类型未正确安装。 Go to the list settings page to delete these fields. 转到列表设置页面以删除这些字段。 at Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) --- End of inner exception stack trace --- at Microsoft.SharePoint.SPGlobal.HandleComException(CO 在Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient,字符串bstrUrl,字符串bstrListName,字符串bstrViewName,字符串bstrViewXml,SAFEARRAYFLAGS fSafeArrayFlags,ISP2DSafeArrayWriter pSACallback,ISPDataCallback pPagingCallback,ISPDataCallback pPagingPrevCallback,ISPDataCallback pFilterLinkCallback,ISPDataCallback pSchemaCallback,ISPDataCallback pRowCountCallback,布尔逻辑pbMaximalView)在Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient,字符串bstrUrl,字符串bstrListName,字符串bstrViewName,字符串bstrViewXml,SAFEARRAYFLAGS fSafeArrayFlags,ISP2DSafeArrayWriter pSACallback,ISPDataCallback pPagingCallback,ISPDataCallback pPagingPrevCallback,ISPDataCallback pFilterLinkCallback,ISPDataCallback pSchemaCallback,ISPDataCallback pRowCountCallback,布尔逻辑pbMaximalView) ---内部异常堆栈跟踪的结尾---在Microsoft.SharePoint.SPGlobal.HandleComException(CO MException comEx) MException comEx)
at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView) at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() at Microsoft.SharePoint.SPFieldCollection.PopulateReturnedFieldsSafeArray() at Microsoft.SharePoint.SPFieldCollection.EnsureFieldsSafeArray(Boolean bGetFullXML) at Microsoft.SharePoint.SPFieldCollection.get_Count() at Microsoft.SharePoint.SPFieldCollection.get_Item(Int32 iIndex) at AZ.SharePoint.RST.AddUsersFromExcelUtility.RSTArchiveSetArea.RSTArchiveSetAreaUserControl.b__0()} 在Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient,字符串bstrUrl,字符串bstrListName,字符串bstrViewName,字符串bstrViewXml,SAFEARRAYFLAGS fSafeArrayFlags,ISP2DSafeArrayWriter pSACallback,ISPDataCallback pPagingCallback,ISPDataCallback pPagingPrevCallback,ISPDataCallback pFilterLinkCallback,ISPDataCallback pSchemaCallback,ISPDataCallback pRowCountCallback,布尔逻辑pbMaximalView)在Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()在Microsoft.SharePoint.SPFieldCollection.PopulateReturnedFieldsSafeArray()在Microsoft.SharePoint.SPFieldCollection.EnsureFieldsSafeArray(Boolean bGetFullXML)在Microsoft.SharePoint.SPFieldCollection.get_Count()在Microsoft.SharePoint.SPFieldCollection.get_Item() (Int32 iIndex)位于AZ.SharePoint.RST.AddUsersFromExcelUtility.RSTArchiveSetArea.RSTArchiveSetAreaUserControl.b__0()}

I have tried creating a custom view with columns getting added one-by-one but it did not work out as well for finding the column with the issue. 我尝试创建一个自定义视图,其中的列被一一添加,但是对于查找有问题的列却效果不佳。 And also have tried adding the column with internal name for referring the CAML query filter but after that too the query does not fetch the required results. 并且还尝试添加带有内部名称的列以引用CAML查询过滤器,但此后查询也无法获取所需的结果。

That error message typically means that there is something wrong with the syntax of your CAML query. 该错误消息通常意味着您的CAML查询的语法有问题。

  • CAML can be sensitive to character casing. CAML可能对字符大小写敏感。 Try changing Type='LOOKUP' to Type='Lookup' 尝试将Type='LOOKUP'更改为Type='Lookup'
  • Make sure that the value of jTitleMappingList.Fields["SET Area"].InternalName resolves to the actual internal name of one of the fields on your list 确保jTitleMappingList.Fields["SET Area"].InternalName解析为列表中字段之一的实际内部名称
  • Make sure that the column you are filtering against is actually a Lookup column, and not some other column type 确保要过滤的列实际上是Lookup列,而不是其他某些列类型

well not sure how you constructed your query, but here's a small example of how it should be : 不太确定如何构造查询,但是下面是一个小示例:

query.Query = "<Where><Eq><FieldRef Name='SharePointFielName' /><Value Type='Text'>" + ddlSubsite.SelectedValue +</Value></Eq></Where>";

This link might help you better understand; 该链接可以帮助您更好地理解;

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.list.getitems(v=office.14).aspx https://msdn.microsoft.com/zh-CN/library/microsoft.sharepoint.client.list.getitems(v=office.14).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM