SharePoint - Value does not fall within the expected range in SPQuery

Asked By Bookworm on 25-Jan-12 04:47 AM
Hi,
im getting this error "Value does not fall within the expected range"
while using this 

 SPList oList = oWebsiteRoot.Lists["List_Name"];

    SPQuery oQuery = new SPQuery();
    oQuery.ViewFields = "<FieldRef Name='Field1'/>" + 
        "<FieldRef Name='Field2'/>";
    oQuery.Query = "<Where><Geq><FieldRef Name='Field2'/>" +
        "<Value Type='Number'>1000</Value></Geq></Where>";
    SPListItemCollection collListItems = oList.GetItems(oQuery);

    foreach (SPListItem oListItem in collListItems)
    {
        .......
    }

Bookworm replied to kalpana aparnathi on 25-Jan-12 05:43 AM
the problem is that i cannot put as a condition the field that is generated from workflow
for example: where Status=2(the number for status in progress)
Sri K replied to Bookworm on 25-Jan-12 05:49 AM

Instead of 

SPQuery query = new SPQuery();

query.ViewFields = string.Format("<FieldRef Name='{0}',(FIELDS.SalesPerson.DisplayName));

I used

SPQuery query = new SPQuery(spList.Views["All Items"]);

Bookworm replied to Sri K on 25-Jan-12 07:19 AM
this shows only the firs page of the list view
for example 30 first records
Bookworm replied to Sri K on 25-Jan-12 08:17 AM
thnx a lot it solve my problem

Sri K replied to Bookworm on 26-Jan-12 06:06 AM
Not at all :-)

Cheers