Hy!
I need to know how to list in a ListBox the name of the tables and the columns that are present into a dataset. After that I want to use this to make a user defined query.
Can anyone help me?!
Dann
Dim x as Data.DataTable
For each x in DataSet1.Tables()
ListBox1.Items.Add(x.TableName)
Dim y as Data.DataColumn
For each y in x.Columns()
ListBox1.Items.Add(" Column - " & y.ColumnName)
Next y
Next x
However, if you're planning to use this for a user-defined query, you probably wouldn't put them together like this. I would have 1 box for Tables (use the OUTER For Loop above) and another box for Columns (the INNER For Loop above). Then, when the user clicked the first box, the second would populate with the items from that table like this:
Code:
Dim y as Data.DataColumn
For each y in DataSet1.Tables(ListBox1.SelectedItem).Rows()
ListBox2.Items.Add(y.ColumnName)
Next y
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.