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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List columns for a data table in dataset

Status
Not open for further replies.

Fred48

Programmer
Feb 23, 2004
62
US
Hi,

I need to retrieve the columns for a particluar data table in a dataset. I was able to find code to process data tables in a dataset but can not find how to process the columns for a table. Below is my code:

Dim dcDataColumn As DataColumn

cnn = New OleDbConnection(PrepareDBConnectStr(sFileName))
cnn.Open()

dtTableNames = cnn.GetSchema("Tables", strRestrictions)
'hicks
For intCounter = 0 To dtTableNames.Rows.Count - 1
Select Case dtTableNames.Rows(intCounter)(2).ToString
Case "tblSearchCriteria"
iCount = iCount + 1

Case "tblHeader"
iCount = iCount + 1
For Each dcDataColumn In dtTableNames.Rows(intCounter).Item(0)
iHeader = iHeader + 1
Next
Case Else

End Select
Next

For table "tblHeader" I want to retrieve all the columns. I think I maybe close but I am still missing a little tweaking.

Thanks!!
 
Code:
        For Each dc As DataColumn In YourDataTable.Columns
            MessageBox.Show(dc.ColumnName)
        Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top