SPListItemCollection.GetDataTable() – be careful

Seems like I am stuck in ADODB days a little bit and I still expect that query with no results returns at least some meta data. Or at least my code gets no bombed by null references. SPListItemCollection has GetDataTable() method that returns items collection as ADO.NET DataTable objects. Be careful when using this method – if your items collection is empty then this method returns null.

 

NB! This blog is moved to gunnarpeipman.com

Click here to go to article

No Comments