How can we load multiple tables in a Dataset?

 Posted by ArticlesMaint on 9/17/2009 | Category: ADO.NET Interview questions | Views: 5406

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 “Data Table” 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” Data Table, use Tables collection of Datasets and the Default view object will give you the necessary output.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response