Connecting Tech Pros Worldwide Forums | Help | Site Map

Getting the index number of a column in a datarow in a strongly typed dataset...

Programatix
Guest
 
Posts: n/a
#1: Dec 11 '05
Hi.

I'm using a strongly typed dataset and I would like to get the index number
of a column from a datarow. Is that possible? I would like to avoid using
expression like this,

myTable.Columns.IndexOf("myColumnName")

Thanks.



Cor Ligthert [MVP]
Guest
 
Posts: n/a
#2: Dec 12 '05

re: Getting the index number of a column in a datarow in a strongly typed dataset...


Programatix,
[color=blue]
> I'm using a strongly typed dataset and I would like to get the index
> number of a column from a datarow. Is that possible? I would like to avoid
> using expression like this,
>
> myTable.Columns.IndexOf("myColumnName")
>[/color]
What expression you like to avoid in this, this is a very normal VBNet
construction and therefore I do not understand it. This will however not
even be enough, you will have to use a fore index loop through the
columnnames which are than 3 rows of code.

Cor


Programatix
Guest
 
Posts: n/a
#3: Dec 12 '05

re: Getting the index number of a column in a datarow in a strongly typed dataset...


As I said, I'm using a strongly typed dataset. Anyway, I found out the way.
Goes something like this,

Let's assume that I have a dataset called dsDataset which a table called
dtTable. There is a column called ID in dtTable.

To retrieve the Index of the column ID,
dsDataset.dtTable.Columns.Indexof(dsDataset.dtTabl e.IDColumn)

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:%23MZDgLu$FHA.3096@TK2MSFTNGP14.phx.gbl...[color=blue]
> Programatix,
>[color=green]
>> I'm using a strongly typed dataset and I would like to get the index
>> number of a column from a datarow. Is that possible? I would like to
>> avoid using expression like this,
>>
>> myTable.Columns.IndexOf("myColumnName")
>>[/color]
> What expression you like to avoid in this, this is a very normal VBNet
> construction and therefore I do not understand it. This will however not
> even be enough, you will have to use a fore index loop through the
> columnnames which are than 3 rows of code.
>
> Cor
>[/color]


Programatix
Guest
 
Posts: n/a
#4: Dec 12 '05

re: Getting the index number of a column in a datarow in a strongly typed dataset...


Now, I can't help wondering which one is faster.... too lazy to go and
benchmark them...

"Programatix" <N$SPAMprogramatixN0000@msn.com> wrote in message
news:e$HZK4u$FHA.1124@TK2MSFTNGP10.phx.gbl...[color=blue]
> As I said, I'm using a strongly typed dataset. Anyway, I found out the
> way. Goes something like this,
>
> Let's assume that I have a dataset called dsDataset which a table called
> dtTable. There is a column called ID in dtTable.
>
> To retrieve the Index of the column ID,
> dsDataset.dtTable.Columns.Indexof(dsDataset.dtTabl e.IDColumn)
>
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:%23MZDgLu$FHA.3096@TK2MSFTNGP14.phx.gbl...[color=green]
>> Programatix,
>>[color=darkred]
>>> I'm using a strongly typed dataset and I would like to get the index
>>> number of a column from a datarow. Is that possible? I would like to
>>> avoid using expression like this,
>>>
>>> myTable.Columns.IndexOf("myColumnName")
>>>[/color]
>> What expression you like to avoid in this, this is a very normal VBNet
>> construction and therefore I do not understand it. This will however not
>> even be enough, you will have to use a fore index loop through the
>> columnnames which are than 3 rows of code.
>>
>> Cor
>>[/color]
>
>[/color]


Closed Thread