|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Determining Sql Column name?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 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 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 > 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 > > 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 >> > > 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 > 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 >
Newbee - Project with single module.
IFormatProvider Change look of button (newbie-VB2005 EE) - filenames in ListBox Method Address from MethodInfo: How do I get it? Service not going to 'Started' How can I control positioning of child windows in an MDI form? MDI Form Position No "MS .NET Framework 1.1 Wizards" Error BC30002 XXXXX Is not defined |
|||||||||||||||||||||||