If you are using a SqlDataReader, which most people are, you can retrieve the field names using the following code
Private Shared Function GetDataRecordColumns(ByVal dr As SqlClient.SqlDataReader) As List(Of String)
'' list to contain the columns
Dim ls As New List(Of String)
For x As Integer = 0 To dr.FieldCount - 1
ls.Add(dr.GetName(x))
Next
Return ls
End Function
In case you are using a dataset or datatable, the following function can be used (Simply pass in your dataset.Table(0) if you are working with a dataset)
Private Shared Function GetDataRecordcolumns(ByVal dt As DataTable) As List(Of String)
Dim ls As New List(Of String)
For Each col As DataColumn In dt.Columns
ls.Add(col.ColumnName)
Next
Return ls
End Function
Hope this helps
G