I'm trying to return a datatable from a query I have written in Subsonic (I'm just starting to learn it) - But can only return a DataSet?
public DataTable GetAllCarTypes()
{
return new Query("tblCarType").ExecuteDataSet();
}
I was hoping for .ExecuteDataTable()??
From stackoverflow
-
Ahhaaa.. should have thought about it before O posted, think I have it now
public DataTable GetAllCarTypes() { return new Query("tblCarType").ExecuteDataSet().Tables[0]; }
If not please can you post up the correct syntax
-
If you're only returning 1 table from the query, you can do:
public DataTable GetAllCarTypes() { return new Query("tblCarType").ExecuteDataSet().Tables[0]; }
Matt : Ugly but correct. SubSonic definitely needs ExecuteDataTable(). Why anyone uses a DataSet when they only need a DataTable is beyond me.
0 comments:
Post a Comment