[Mono-list] asking for null DataSet

Carlos Ble carlosble at shidix.com
Wed Oct 26 14:01:50 EDT 2005


Hi
I tried to ask for a null DataSet to determine when a SELECT query
return nothing. DataSet are filled with NpgsqlDataAdapter.Fill method.
This method never returns null. So you can't ask 
if (dataset == null).
Searching for DataSet.Tables property I found this from msdn:
A DataRowCollection that contains DataRow objects; otherwise a null
value if no DataRow objects exist.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatatableclassrowstopic.asp

So I tried with dataset.Tables == null but isn't null, because in
DbDataAdapter, an empty table with real name extracted from SetupSchema
are added to dataset. 
The solution is to ask
if (dataset.Tables[0].Rows.Count == 0)

Is this a good mechanism?
Could this code run in .Net too? 













More information about the Mono-list mailing list