All SPQuery examples
Query for Date type Column in SharePoint
The above query is to find the items which has Date column with value less than Today's Date. The results will be returned in a Descending manner so you can get the most recently entered items from the List.
Query on Date Yes\No columns :
Monday, March 31, 2008
SPQuery Examples
Tuesday, March 25, 2008
SPSiteDataQuery

You Can query multiple lists/Libraries of same kind for common fields in them. This Query returns a Datatable,which can be used as a source to a Calendar or GridView etc.
Query above will serach all the lists(Specified by Basetype = '0') for column name "EventDate" and value as Today's date. And returns Title , EventDate,Description,ListName(custom field in event List) in a form of a Table.
You can also Specify the List's to search in the scope! You need to provide the Guid of the List for that .
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\
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)
{
}
Friday, February 15, 2008
A Tip for Writing SPQuery
To Use a SPQuery for getting the desired List data, We use Sharepoint's SPQuery class.
Some Important Notes about Using SPQuery.
* Use the Column Names that were kept Orignally when the Colum was made for the first time.(Not the ones that you see on column header,they may be same as they were kept earlier or may be not).
For eg, If you created a column with name "BName" and you changed the name(rename) to "BusinessName" later. You will have to use" BName" in SPQuery for getting the BusinessName column data Not "BusinessName".
More on SPQuery:
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spquery.aspx
