Here is my code:

SPList list = web.Lists["List1"];
SPQuery query = new SPQuery();
query.Query = @"<Where>" +
                   "<And>" +
                       "<Eq>" +
                         "<FieldRef Name='Activity_x0020_Status'/>" +
                         "<Value Type='Text'>Completed</Value>" +
                       "</Eq>" +
                       "<Geq>" +
                         "<FieldRef Name='Start_x0020_Date'/>" +
                         "<Value Type='DateTime' IncludeTimeValue='FALSE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(dtStart) + "</Value>" +
                      "</Geq>" +                                                
                   "</And>" +

 query.Joins = string.Concat(@"<Join Type='LEFT' ListAlias='List2'>" +
                                "<FieldRef Name='Client_x003a_' RefType='ID'/>" +
                                "<FieldRef List='List2' Name='ID'/>" +
                              "</Eq>" +

  query.ProjectedFields = @"<Field Name='Location' Type='Lookup' List='List2' ShowField='Location'/>";

 query.ViewFields = "<FieldRef Name='Start_x0020_Date'/><FieldRef Name='Hours_x0020_Approved'/><FieldRef Name='Location'/>";
DataTable dt = list.GetItems(query).GetDataTable();

While converting it into Datatable I am facing this issue. I was trying to debug and when I reached at the last line I was thrown in the catch block with the above error.

  • where are you getting the error? your post should be a little more descriptive. – Taran Goel Aug 11 '15 at 12:26
  • Just for debugging this and making sure, can you remove the join and check if you still get the error? – Akhoy Aug 11 '15 at 12:42
  • No after removing the join I am not facing any error. Error is in join statement I guess. – DRS Aug 11 '15 at 13:25
  • You are missing a + on the second line of the join string – theChrisKent Aug 11 '15 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.