How to get DataTable

Dec 15, 2012 at 12:17 PM
I want to get DataTable using select query like

Dec 17, 2012 at 8:40 PM

Try the DBDatabase.PopulateDataSet(...) method.

Pass in the DataSet, the DBQuery and the name(s) of the table(s) you want to fill.

There are 16 overloads so should be something for you.

Dec 18, 2012 at 5:15 AM

I tried using this code

DataSet dsTable = new DataSet();

dsTable.Tables.Add(new DataTable("Table"));

DBQuery query = DBQuery.SelectAll().From(tableName);

Constants.DATABASE.PopulateDataSet(dsTable, query);


it works fine but give error when there is no data present in database table - "tableName"

Dec 20, 2012 at 6:01 AM

Have you tried the methods on the data table itself.

DBQuery sel = DBQuery.SelectAll().From("Table");

db.ExecuteRead(sql, reader =>
     DataTable dt = new DataTable();

//do something with your table

Dec 25, 2012 at 8:03 AM

Thanks it's usefull for me and also work if there is no data present in table