簡體   English   中英

無法使用CAML查詢獲取Sharepoint列表數據

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

我正在嘗試使用下面列出的CAML查詢從SP列表中獲取數據。

CAML查詢

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

遇到錯誤消息:

{Microsoft.SharePoint.SPException:一種或多種字段類型未正確安裝。 轉到列表設置頁面以刪除這些字段。 ---> System.Runtime.InteropServices.COMException(0x81020014):一種或多種字段類型未正確安裝。 轉到列表設置頁面以刪除這些字段。 在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)
在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()}

我嘗試創建一個自定義視圖,其中的列被一一添加,但是對於查找有問題的列卻效果不佳。 並且還嘗試添加帶有內部名稱的列以引用CAML查詢過濾器,但此后查詢也無法獲取所需的結果。

該錯誤消息通常意味着您的CAML查詢的語法有問題。

  • CAML可能對字符大小寫敏感。 嘗試將Type='LOOKUP'更改為Type='Lookup'
  • 確保jTitleMappingList.Fields["SET Area"].InternalName解析為列表中字段之一的實際內部名稱
  • 確保要過濾的列實際上是Lookup列,而不是其他某些列類型

不太確定如何構造查詢,但是下面是一個小示例:

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

該鏈接可以幫助您更好地理解;

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