GetChanges gives null column value in error

  • Thread starter Thread starter kcakebread
  • Start date Start date
K

kcakebread

Using VB 2005, I have a strongly typed dataset (from a .xsd file in my
project).

When I load data into this dataset, the immediate window shows:
?ds.TableX(0).IstheFieldNull
True

So, dutifully, I give it a value:
ds.TableX(0).theField = "testabc123"

I can look in the immediate window and see:
?ds.TableX(0).IstheFieldNull
False
?ds.TableX(0).theField
"testabc123"

However, I can also see:
?CType(ds.GetChanges, dsObjectType).TableX(0).IstheFieldNull
True

Clearly, GetChanges() recognized the TableX(0) row was modified, but it
failed to include my column value. Furthermore, if I:
ds.writexml("c:\ds.xml")
ds.GetChanges().WriteXML("c:\dschanges.xml")

I see that the row of interest is in the XML, but the column is
actually missing (ie null).

Anyone have any ideas?

Kerry
 
Just to ask the obviously basic, did you BeginEdit and EndEdit the row?
GetChanges should reflect the modified values and no the original values.

CType(ds.GetChanges, dsObjectType).TableX(0).IstheFieldNull, will not
necessarily be the row you think it is, as this is a subset of your original
table.

try this

if ds.TableX.rows(0).IstheFieldNull then
ds.TableX.rows(0).beginedit
ds.TableX.rows(0)("TheField") = "SomeValue"
ds.TableX.rows(0).endedit
debug.writeline(ds.TableX.rows(0).rowstate)
end if
 
Back
Top