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!

Get column names from SQL data source for drop down list

Status
Not open for further replies.
Jan 23, 2002
63
0
0
US
Hi,

I'm using VB.net 2008 and SQL 2008. I've got a SQL data source that works fine, but I need to get the column names from it so that I can fill a drop down. But there's no "table" element in the data source, and nothing else that I can see that would give me the column names. The data source is attached to a SQL view.

 

Something like:
Code:
Friend dsDtSet As New DataSet
Dim dt As DataTable

dt = dsDtSet.Tables("MyTableName")

For Each column As DataColumn In dt.Columns
    Debug.Print(column.Caption.ToString & " is " & column.DataType.ToString)
Next

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top