SharePoint 2013 多表查询的 0x80070057 错误

环境:SharePoint 2013
场景:在SharePoint 2013 下面进行多表查询。

做表报的时候要做多表查询,然后百度到SPQuery,然后照着写,一直报下面这个错误。。。

System.ArgumentException: 0x80070057 在 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) 在 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) 在 Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() 在 Microsoft.SharePoint.SPListItemCollection.GetEnumerator() 在 Amway.DataCenterMaintenance.Web.WebPart.StepExportWP.StepExportWPUserControl.b__0() 在 Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.b__3() 在 Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) 在 Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) 在 Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) 在 Amway.DataCenterMaintenance.Web.WebPart.StepExportWP.StepExportWPUserControl.btnExport_Click(Object sender, EventArgs e)

被坑了一天。。。
其实很简单的。。。

主要是SPQuery的ProjectedFields里面的字段的类型都需要用Lookup,我之前用他们的List中的字段的类型了,然后就一直报上面那个错误了。

SPList stepList = web.GetList(web.Url + "/Lists/StepList");

                            SPQuery query = new SPQuery();
                            query.Query = @"<Where>
                                              <IsNotNull>
                                                 <FieldRef Name='ID' />
                                              </IsNotNull>
                                           </Where>
                                            <OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy>";
                            query.Joins = "<Join Type='LEFT' ListAlias='WorkSheetList'><Eq><FieldRef Name='WorkSheetList' RefType='ID'/><FieldRef List='WorkSheetList' Name='ID'/></Eq></Join>";
                            query.ProjectedFields = @"<Field Name='WorkSheetID' Type='Lookup' List='WorkSheetList' ShowField='ID'/>
                                                               <Field Name=''WorkSheetTitle' Type='Lookup' List='WorkSheetList' ShowField='Title'/>";

希望对刚接触SharePoint的你有用。。。

猜你喜欢

转载自blog.csdn.net/u012835032/article/details/78663740