Assigning/Updating values to DataTable

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

in VStudio 2005 visual basic.net

How do I change a single value in a single cell in a datatable that already
exists.

E.g.,

Dim MyTable As New DataTable

<code that reads from a db and places it into MyTable>

MyTable.Rows(0)(0) = <whatever> <- this, obviously, doesn't work, but
what will?

More specifically, lets say that I need to place 1 into row 0 column 0

Will the same code work if the Table is currently all null values?

Thanks

Jeff
 
Jeff,
MyTable.Rows(0)(0) = <whatever> <- this, obviously, doesn't work,
but what will?
What is the error that you get when you do this?
Because this should work

Cor
 
Cor Ligthert said:
Jeff,

What is the error that you get when you do this?
Because this should work

Cor

I figured it out. ...was placing the results of a query into the table
first. If the query didn't return anything and the table was initally empty,
I needed to add a row first. Afterward, the code was fine.

Thanks

Jeff
 
Back
Top