Probably a really simple way to do this but I cant work out how or find any documentation on how to retrieve the column names of a table e.g. using the bindingsource
could someone help?
Printable View
Probably a really simple way to do this but I cant work out how or find any documentation on how to retrieve the column names of a table e.g. using the bindingsource
could someone help?
DataTable class has Columns property which returns a DataColumn collection. And DataColumn class has ColumnName property that gives you the name of the datacolumn.... Put all together, you will need to get the columns collection from the datatable and loop thru it to get the individual column names. Something like this:
Code:Dim myDataTable As DataTable = CType(myBindingSource.DataSource, DataTable)
For Each column As DataColumn In myDataTable.Columns
MessageBox.Show(column.ColumnName)
Next
That doesn't work as myBindingSource.DataSource returns a DataSet rather than the actual table in the DataSetQuote:
Originally Posted by stanav
Nevermind got it sorted! thanks for the help