Dataset Merge Problem

  • Thread starter Thread starter Dana L. Stille
  • Start date Start date
D

Dana L. Stille

I have a crystal report that I want to print using a single record. I want to report on any changes that have taken place through the bound controls. I am using the following code to get the current row that is being displayed (MOD_NO is the primary key field), and merging it into a dataset to be used in the report.

Dim CurrentRow() As dsSCRData.scrdataRow = SCRDataSet.Tables(AC.SCRSettings.TableName).Select("MOD_NO = '" & txtModNo.Text & "'")

dsCurrentSCR.Merge(CurrentRow, False, MissingSchemaAction.Ignore)

Dim SCRReport As New rptSCR

SCRReport.SetDataSource(dsCurrentSCR)

The problem is that when I view the report the values that changed in the bound controls are not reflected in the report. While debugging this code I can see that the change is being correctly reflected in the DataRow "CurrentRow." However, the change does not get placed in the dataset. I used specified "FALSE" for the "preserveChanges" parameter in the Merge method. Also, when I view the row state in the dataset "dsCurrentSCR" it is set to "Unchanged". What am I doing wrong?
 
Thanks for the tip, but this did not make any difference. The changes are
still not retained after the merge and acceptchanges calls.
 
Piyush,

I just wanted to let you know I found the problem. It was related to
AcceptChanges(), but was related to the DataRow.AcceptChanges(). What I did
was called the AcceptChanges() method on the DataRow before I called the
DataSet.Merge() method, then I called the DataSet.AcceptChanges() method.
Now my changes are reflected in the report. Here is the final version of the
lines of code for your reference.

Dim CurrentRow() As dsSCRData.scrdataRow =
SCRDataSet.Tables(AC.SCRSettings.TableName).Select("MOD_NO = '" &
txtModNo.Text & "'")

CurrentRow(0).AcceptChanges()

dsCurrentSCR.Merge(CurrentRow, False, MissingSchemaAction.AddWithKey)

dsCurrentSCR.AcceptChanges()

Dim SCRReport As New rptSCR

SCRReport.SetDataSource(dsCurrentSCR)



This problem was elusive. I hope this will help someone else save time in
the future. Take care and God Bless!
 
Back
Top