We help IT Professionals succeed at work.

Bug or am I doing something wrong?

I have a form that displays detail of a record.  When the Form loads it fill the Form controls with the values of a single record by passing it a PK value. I have an Add button that clears the controls and allows entry of new information.  I also have some rudimentary validation behind the DataSet in its partial class. It is triggered by ColumnChanged. When there is invalid data this line is executed:
DataRecord.SetColumnError("CustomerCode", "Invalid Customer Code")
Whatis happening is that the first time I change a Column and this line is fired it fills all the controls on the form with values that were there before I cleared it. It does not change the column that I added something from which I changed.
Watch Question

The dataset represents an in-memory cache of data
You have to use the DataSet.AcceptChanges Method
See the example bellow. it might help
Private Sub AcceptChanges()
   Dim myDataSet As DataSet
   myDataSet = new DataSet()
   ' Not shown: methods to fill the DataSet with data.
   Dim t As DataTable
   t = myDataSet.Tables("Suppliers")
   ' Add a DataRow to a table.
   Dim myRow As DataRow
   myRow = t.NewRow()
   myRow("CompanyID") = "NWTRADECO"
   myRow("CompanyName") = "NortWest Trade Company"
   ' Add the row.
   t.Rows.Add( myRow )
   ' Calling AcceptChanges on the DataSet causes AcceptChanges to be
   ' called on all subordinate objects.
End Sub

Open in new window


i am actually a little confused on what you want to happen

<<It does not change the column that I added something from which I changed.>>

what do you mean by this.-- are you actually trying to clear the values in the dataset from which you passed a record to this form?? do you want to remove?? how are you binding to your controls on the form displaying the record? what controls are you using?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.