Home All Groups Group Topic Archive Search About

newbie - get value of field from datatable syntax

Author
31 Oct 2005 3:38 PM
Steve
I have a datatable containing 1 row and a few columns.

I simply want to retrieve the value of the 'nameid' column and store it
as an integer in a variable.

Dim data As Data.DataTable
data = MyObject.MyMethod(parameter) 'Returns 1 row with several columns
including a 'nameid' column

Dim id as Integer
id = 'value in the nameid column (don't know syntax)

I am coding vb.net in asp.net 2.0

Author
31 Oct 2005 5:29 PM
Cowboy (Gregory A. Beamer) - MVP
id = CType(data.Rows(0).("nameid"), Integer)

is the safest, assuming there is only one row, of course. Strongly typed
DataSets/tables make it even easier.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


Show quote
"Steve" wrote:

> I have a datatable containing 1 row and a few columns.
>
> I simply want to retrieve the value of the 'nameid' column and store it
> as an integer in a variable.
>
> Dim data As Data.DataTable
> data = MyObject.MyMethod(parameter) 'Returns 1 row with several columns
> including a 'nameid' column
>
> Dim id as Integer
> id = 'value in the nameid column (don't know syntax)
>
> I am coding vb.net in asp.net 2.0
>
>
Author
31 Oct 2005 5:39 PM
Steve
Thanks a lot Gregory. I appreciate it.

AddThis Social Bookmark Button