Imports cell from DataTable

I have a DataTable with many Columns

i want to imports Data From one Column and add it to a variable

How do i do it in VB ?

[142 byte] By [Elad_23] at [2007-12-24]
# 1

usually its something like this:

Dim theColumnItem as Object = theDataTable.Rows(index).ItemArray(index)

or

Dim theColumnItem as object = theDataTable.Rows(index)(ColumnName)

does this answer your question?

ahmedilyas at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2

yes thanks

and How do I convert this object to an Integer ?

Elad_23 at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3

you have 2 ways

  • direct convert

  • try to convert - better option

    Dim theResult as Integer

    If Integer.TryParse(theColumn.ToString(), theResult) then

    'successfully converted "theColumn" object to an Integer and result is saved in "theResult"

    end if

  • ahmedilyas at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

    .NET Development

    Site Classified