Determining Sql Column name?

  • Thread starter Thread starter rowe_newsgroups
  • Start date Start date
Sorry, guess I read your post wrong (got thrown off by the post title)
- I thought you were looking for the column name of a SQL Server table.

Thanks,

Seth Rowe
 
The code below will correctly locate the last entry in a particular SQL Table in VWeb 2005 with VB.

How can I determine the column name associated with the column number x?

Dim tempA As System.Data.DataView
tempA = GetPriorAnswers()
Dim x As Integer
Dim temp As Integer = Session("Pointer")
For i As Integer = 1 To 10000
x = temp - i
If Len(tempA.Item(0)(x).ToString) > 0 Then
Exit For
End If
Next
<at this point, x is the column number for the last entry in the table - what code will return the column name?>

Thanks in advance

Jeff
 
The "DataColumns" part of your syntax didn't work, but the following minor modification did.
ColName = tempA.ToTable.Columns(x).ColumnName()

Thanks. ...not sure why the original didn't work, but perhaps related to something I would need to import first?

Jeff
 
Jeff,

This works however I made a mistake while typing, now you are copying the
table first my intention was

ColName = tempA.Table.Columns(x).ColumnName()

Than it is just using the table,


Cor
 
Back
Top