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
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