How can we load multiple tables into Dataset?
How can we load multiple tables into Dataset
Hi all,
How can we load multiple tables into Dataset?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
raghu vPosted Jun 13, 2011, 4:36 AM
the previous answers are clear to explain u doubt and if u are still in confusion i hope u know how to fill the data set using dataadaptor then u can follow the following way to store multi results in a data set
sqldatadataptor da = new sqldataadaptor("select * from table1","conn");
dataset ds= new dataset();
da.fill(ds,"table1");// here table1 is the virtual table name for the result set 1
da=new sqladaptor("select * from table2","conn");
da.fill(ds,"table2");//here table2 is virtual table name for the result set 2
now u can get the data from which ever table set u desired
gridview grdview1 =new gridview();
gridview1.datasource=ds.tables["table1"];//if u want to use table1
gridview1.datasource = ds.tables["table2"];//if u want to use table 2
Note:if u just bind fill the data in to dataset with out virtual names then u can access ur table from data set using index
like grdview1.datasource=ds.tables[0];/ds.tables[1]'
Sam HobbsPosted Jun 11, 2011, 6:12 PM
Pradeep ChandrakerPosted Jun 10, 2011, 1:52 PM
DataSet ds = new DataSet();
DataTable dt1 = new DataTable();
ds.Tables.Add(dt1);
DataTable dt2 = new DataTable();
ds.Tables.Add(dt2);
Posted Jun 10, 2011, 3:11 AM
select * from table1
select * from table2 etc.
This will create two tables inside the database.
You can manually also create datatable and add it into the dataset.