Home All Groups Group Topic Archive Search About

Determining Sql Column name?

Author
18 Sep 2006 5:18 PM
Jeff
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




--
Posted via a free Usenet account from http://www.teranews.com

Author
18 Sep 2006 4:48 PM
rowe_newsgroups
Check out http://support.sas.com/ctx/samples/index.jsp?sid=817
About midway down it talks about using the schema data to retrieve this
(with ADO.Net)

Thanks,

Seth Rowe

Jeff wrote:
Show quoteHide quote
> 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
>
>
>
>
> --
> Posted via a free Usenet account from http://www.teranews.com
Author
18 Sep 2006 5:02 PM
Cor Ligthert [MVP]
Jeff,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclasstabletopic.asp

dim dcname as string =  TempA.ToTable.DataColumns(x).Columnname

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclasscolumnnametopic.asp

I hope this helps,

Cor

Show quoteHide quote
"Jeff" <n***@none.com> schreef in bericht
news:450eb95e$0$19611$88260bb3@free.teranews.com...
>
>
>
> 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
>
>
>
>
> --
> Posted via a free Usenet account from http://www.teranews.com
>
Author
18 Sep 2006 5:10 PM
rowe_newsgroups
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

Cor Ligthert [MVP] wrote:
Show quoteHide quote
> Jeff,
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclasstabletopic.asp
>
> dim dcname as string =  TempA.ToTable.DataColumns(x).Columnname
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclasscolumnnametopic.asp
>
> I hope this helps,
>
> Cor
>
> "Jeff" <n***@none.com> schreef in bericht
> news:450eb95e$0$19611$88260bb3@free.teranews.com...
> >
> >
> >
> > 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
> >
> >
> >
> >
> > --
> > Posted via a free Usenet account from http://www.teranews.com
> >
Author
18 Sep 2006 5:23 PM
Cor Ligthert [MVP]
Jeff,

You are right if the select is renaming the table names, as long as that is
not done, this is correct.

Another way is using this.

http://www.vb-tips.com/dbpages.aspx?ID=26f91edd-044c-4e71-8c6c-e9d7983c1e05

I hope this helps,

Cor

Show quoteHide quote
"rowe_newsgroups" <rowe_em***@yahoo.com> schreef in bericht
news:1158599403.731863.248950@e3g2000cwe.googlegroups.com...
> 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
>
> Cor Ligthert [MVP] wrote:
>> Jeff,
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclasstabletopic.asp
>>
>> dim dcname as string =  TempA.ToTable.DataColumns(x).Columnname
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclasscolumnnametopic.asp
>>
>> I hope this helps,
>>
>> Cor
>>
>> "Jeff" <n***@none.com> schreef in bericht
>> news:450eb95e$0$19611$88260bb3@free.teranews.com...
>> >
>> >
>> >
>> > 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
>> >
>> >
>> >
>> >
>> > --
>> > Posted via a free Usenet account from http://www.teranews.com
>> >
>
Author
18 Sep 2006 7:15 PM
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


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23SPIHQ02GHA.1548@TK2MSFTNGP02.phx.gbl...
> Jeff,
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclasstabletopic.asp
>
> dim dcname as string =  TempA.ToTable.DataColumns(x).Columnname
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclasscolumnnametopic.asp
>
> I hope this helps,
>
> Cor
>



--
Posted via a free Usenet account from http://www.teranews.com
Author
19 Sep 2006 4:38 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Jeff" <n***@none.com> schreef in bericht
news:450ed4bb$0$19706$88260bb3@free.teranews.com...
>
> 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
>
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:%23SPIHQ02GHA.1548@TK2MSFTNGP02.phx.gbl...
>> Jeff,
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadataviewclasstabletopic.asp
>>
>> dim dcname as string =  TempA.ToTable.DataColumns(x).Columnname
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclasscolumnnametopic.asp
>>
>> I hope this helps,
>>
>> Cor
>>
>
>
>
> --
> Posted via a free Usenet account from http://www.teranews.com
>