Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User defined query

Status
Not open for further replies.

dannG

Programmer
Jan 9, 2003
26
0
0
RO
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
 
All in the same listbox?
Code:
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
This will give you a list like so:

Table1
Column - Col1
Column - Col2
Table2
Column - Col3
Column - Col4

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


Ben

There's no place like 127.0.0.1.
 
Thanks.
I was very close to this!
Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top