Assigning/Updating values to DataTable

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
 
C

Cor Ligthert [MVP]

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
 
J

Jeff

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top