How can we load multiple tables in a DataSet

Q

How can we load multiple tables in a DataSet ?

✍: Guest

A
objCommand.CommandText = "Table1"
objDataAdapter.Fill(objDataSet, "Table1")
objCommand.CommandText = "Table2"
objDataAdapter.Fill(objDataSet, "Table2")

Above is a sample code which shows how to load multiple “DataTable” objects in one “DataSet” object. Sample code shows two tables “Table1” and “Table2” in object ObjDataSet.

lstdata.DataSource = objDataSet.Tables("Table1").DefaultView

In order to refer “Table1” DataTable, use Tables collection of DataSet and the Defaultview object will give you the necessary output.

2007-10-24, 4580👍, 0💬