I am trying to query a custom list and getting the following error:

enter image description here


SPListItemCollection OsplistitemCollection = Olist.GetItems(OqueryResponse);

below is my code

string TicketID = "123";
Osite = new SPSite(noPrevSite.ID);
Oweb = Osite.OpenWeb(noPrevWeb.ID);
Olist = Oweb.Lists["ListName"];

helpDeskIDLabel.Text = TicketID;
camlQuery = "<Where><Contains><FieldRef Name='TicketID'/<Value Type='Text'>" 
                      + TicketID+ "</Value></Contains></Where>";
OqueryResponse.Query = camlQuery; 
SPListItemCollection OsplistitemCollection = Olist.GetItems(OqueryResponse);
string count = OsplistitemCollection.Count.ToString();

Update -->ULS Log

Unable to execute query: Error 0x81020014 One or more field types are not installed properly. Go to the list settings page to delete these fields.

  • 1
    Please verify that this is code you are using because even after I applied some formating it looks... confusing. Btw one > is missing after TicketID in query string (?) Commented Feb 8, 2012 at 20:15
  • yes it was wil copy pasting it that i miss the >
    – SandeshR
    Commented Feb 9, 2012 at 17:13

2 Answers 2


You get that error when the fields used in CAML query fields or viewfields are not present in that list. CAML uses the internal name and not the display name. Verify that the ticketid is the internal name of that field and not display name. Go to list settings and click on the field ticketid and observe the url for the param value 'field'. This should match the one used in CAML. It is very likely that someone changed the column's display name after it was created, so the display name would be different from the internal name.

  • I would bet this is the likely cause of the problem. I cannot count the number of times I have changed the Title field's display name and then forgotten that I did this afterwards. Commented Mar 13, 2012 at 0:39
  • yeah right check your fields properly
    – naijacoder
    Commented Mar 13, 2012 at 7:30

If TicketID is text field and your goal is to get all tickets containing some value then code (written from head!) is:

string TicketId = "123";
using(SPSite oSite = new SPSite(noPrevSite.ID)
    using(SPWeb oWeb = oSite.OpenWeb(noPrevWeb.ID))
         SPList oList = oWeb.Lists["ListName"];
         SPQuery query = new SPQuery();
         query.Query = "<Where><Contains><FieldRef Name='TicketID'/><Value Type='Text'>" 
                  + TicketId + "</Value></Contains></Where>";
         SPListItemCollection oSplistitemCollection = oList.GetItems(query);
         string count = oSplistitemCollection.Count.ToString();

Also it is not a bad idea to check your list and verify that TicketID is present. However there are other reasons for this query to fail but you need to provide more info and recheck that code you provided is really one you are using (see my comment).

  • hi vedran, i did check the ticketid,it is present in the list ..the custom list that i m using here is actually a custom list template from the production..and we did lotus notes migration on that list...does that might have caused the problem?..thanks
    – SandeshR
    Commented Feb 9, 2012 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.