Visit our SharePoint Forum

SharePoint developer? Submit Yourself as Freelancer

Wednesday, February 20, 2008

Using SPQuery with Yes/No Columns

To use Yes/No fields with SPQuery,You need to keep in mind some important things.

When you want to query the value for Yes/NO fields in SPQuery,
1. Use value type \"bit\" Not \"Text\
2. Use '1' for Yes & '0' for NO.

Note: Value type Text work fine with Yes/NO columns in MOSS 2007 but not in WSS.
So, If you are using WSS then you need to use bit not text.

Its always better to use CAML query builder to build a query, and then copy-paste that in SPQuery object.

To use Yes/No columns

if (Convert.ToBoolean(NewsItem["Publish?"]) == true)
{

}

1 comments:

Anonymous said...

Convert.ToBoolean(itemCollection[0]["Used_In_Stories"].ToString()

SharePoint Programming