我有一个CAML
查询,它从SharePoint
列表中检索数据。
//orQuery with 1 input executes successfully
string orQuery = "<FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value>";
string subQuery = "<Neq><FieldRef Name =\"ContentType\"/><Value Type=\"Text\">{0}</Value></Neq>".FormatWith("Document");
var query = new SPQuery(view)
{
Query = "<Where><And><Eq>{0}</Eq>{1}</And></Where>".FormatWith(orQuery, subQuery),
ViewAttributes = "Scope=\"RecursiveAll\"",
ViewFields = @"<FieldRef Name='RecordTitle'/>",
};
但是,当我如下更改orQuery
以接受多个输入时,它失败了:
//orQuery with 2 input execute failed
string orQuery = "<Or><FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value>
<FieldRef Name="Header1Ref"/><Value Type="Text">H2</Value></Or>"
记录的错误:
Microsoft.SharePoint.SPException:一种或多种字段类型不是正确安装。转到列表设置页面以删除这些领域。 ---> System.Runtime.InteropServices.COMException:一个或多个字段类型未正确安装。转到列表设置页面删除这些字段.0x81020014在Microsoft.SharePoint.Library.SPRequestInternalClass.GetListItemDataWithCallback2(IListItemSqlClientpSqlClient,字符串bstrUrl,字符串bstrListName,字符串bstrViewName,字符串bstrViewXml,SAFEARRAYFLAGS fSafeArrayFlags,ISP2DSafeArrayWriter pSACallback,ISPDataCallback pPagingCallback,ISPDataCallback pPagingPrevCallback,ISPDataCallbackpFilterLinkCallback,ISPDataCallback pSchemaCallback,ISPDataCallbackpRowCountCallback,Boolean&pbMaximalView)Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClientpSqlClient,字符串bstrUrl,字符串bstrListName,字符串bstrViewName,字符串bstrViewXml,SAFEARRAYFLAGS fSafeArrayFlags,ISP2DSafeArrayWriter pSACallback,ISPDataCallback pPagingCallback,ISPDataCallback pPagingPrevCallback,ISPDataCallbackpFilterLinkCallback,ISPDataCallback pSchemaCallback,ISPDataCallbackpRowCountCallback,Boolean&pbMaximalView)-内部结束异常堆栈跟踪---Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)在Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClientpSqlClient,字符串bstrUrl,字符串bstrListName,字符串bstrViewName,字符串bstrViewXml,SAFEARRAYFLAGS fSafeArrayFlags,ISP2DSafeArrayWriter pSACallback,ISPDataCallback pPagingCallback,ISPDataCallback pPagingPrevCallback,ISPDataCallbackpFilterLinkCallback,ISPDataCallback pSchemaCallback,ISPDataCallbackpRowCountCallback,Boolean&pbMaximalView)Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()在Microsoft.SharePoint.SPListItemCollection.get_Count()在Admin.Report.FilePlanReport.FilePlanReportUserControl.GetData()
我对错误的研究表明,可能是由于列InternalName
与CAML查询的不匹配。但是,我的第一个查询设法成功执行...
如果输入多于1个,是否可以由CAML
查询的格式结构错误引起?
谢谢。
这是CAML查询的问题,我将代码修改如下,以供您参考。