2
Reply

Several tables in the same DataSet

Carlos Sanchez

Carlos Sanchez

Jul 15 2004 10:56 AM
2.1k
I want to know wether or not is possible having several tables in a DataSet. For example, when I want to create a DataSet I have to do the next: string commandText = "SELECT Column1, Column2 FROM Table1"; SqlDataAdapter myAdapter = new SqlDataAdapter(commandText, myConnection); DataSet myDataSet = new DataSet(); myAdapter.Fill(myDataSet, "Table1"); If I wanted to Bind the DataSet with a component (for example ComboBox) I'd do the next: ComboBox1.DataSource = myDataSet.Tables["Table1"]; ComboBox1.DisplayMember = "Column1"; So, I want to know wether I can have several tables in the same DataSet to Bind them with several components, something like this: ComboBox1.DataSource = myDataSet.Tables["Table1"]; ComboBox2.DataSource = myDataSet.Tables["Table2"]; ComboBox3.DataSource = myDataSet.Tables["Table3"]; ComboBox4.DataSource = myDataSet.Tables["Table4"]; is this possible??? How can I do it??? if you know what can I do, paste some code please. thanks in advance.

Answers (2)