Replacing values in a datatable

J

jhcorey

I'm looking at some code where a column was added to a datatable and
then given
a value. It works fine. But if I try to update a previously existing
column,
it doesn't take. No error is thrown, it just doesn't get updated.
I've tried
a few variations, and I'm trying to avoid creating a new datatable.
An example of what works and what doesn't is shown below.
Any quick and easy solutions?


myDataTable.Columns.Add("Class",
System.Type.GetType("System.String"))
myDataTable.Columns("Class").AllowDBNull = True

For Each myDataRow In myDataTable.Rows
'OK
myDataRow("Class") = CType(myDataRow("CATG_NUM"),
String).Substring(0, 2)
'Not Ok -- it doesn't get updated
myDataRow("CATG_NUM") = myString
Next
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top