BeginEdit and EndEdit question

B

Brad

I am having a data disappearance problem. On an edit routine, I have one
row of data being pulled into the dataset that is then displayed on a form.
The fields are bound to their respective controls. At the time that the SQL
query is run and that one data row is displayed, I am calling the
row(0).BeginEdit method. The user edits the data and then hits Save which
then I call the row(0).EndEdit method and also the dataAdapter.Update(ds).
For some reason some of the data that is displayed but not edited is not
being save back to the original datasource after the edit and these fields
now have null information. This is not good as some of the fields are text
memo fields and have to be re-typed.

What am I doing wrong here. Here is a snippet of code:

Editing the row:
DsEditReview1.Tables(0).Rows(0).BeginEdit()

Saving the changes:
DsEditReview1.Tables(0).Rows(0).Item("PlanR") =
CInt(CStr(cmbPlan.Text.Chars(0)))

DsEditReview1.Tables(0).Rows(0).Item("PlanT") = cmbPlan.Text.Remove(0, 3)

DsEditReview1.Tables(0).Rows(0).Item("PlanN") = txtPlan.Text

DsEditReview1.Tables(0).Rows(0).Item("ProbR") =
CInt(CStr(cmbProbSolv.Text.Chars(0)))

DsEditReview1.Tables(0).Rows(0).Item("ProbT") = cmbProbSolv.Text.Remove(0,
3)

DsEditReview1.Tables(0).Rows(0).Item("ProbN") = txtProbSolv.Text

DsEditReview1.Tables(0).Rows(0).Item("QualR") =
CInt(CStr(cmbQuality.Text.Chars(0)))

DsEditReview1.Tables(0).Rows(0).Item("QualT") = cmbQuality.Text.Remove(0, 3)

DsEditReview1.Tables(0).Rows(0).Item("QualN") = txtQual.Text

DsEditReview1.Tables(0).Rows(0).Item("AttendR") =
CInt(CStr(cmbAttend.Text.Chars(0)))

DsEditReview1.Tables(0).Rows(0).Item("AttendT") = cmbAttend.Text.Remove(0,
3)

DsEditReview1.Tables(0).Rows(0).Item("AttendN") = txtAttend.Text

DsEditReview1.Tables(0).Rows(0).EndEdit()

daEditReview.Update(DsEditReview1)
 
T

Trygve Lorentzen

You should try to check the contents of the dataset columns if they are set
to the correct values. One simple way to do this is:

DsEditReview1.WriteXML("filepath") where filepath could be f.ex
F:\projects\logs\DsEditReview1.xml

You can use the XmlWriteMethod.DiffGram (think this is correct syntax :) )
to see before and after values too, this is really nice, like this:

DsEditReview1.WriteXML("filepath", XmlWriteMethod.DiffGram)

Hope this helps!

Cheers,
Trygve
 

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