Bound controls do not copy across data to underlying data row

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a small app with bound controls that do not seem to be copying across
the data entered into them to the underlying row for the update. This one
really has me stump even though these are very simple steps and I can't see
where I am going wrong. Any help would be appreciated.

The relevant code goes as follows;

Binding controls

Dim db As System.Windows.Forms.Binding
ds = MyDataset
db = New System.Windows.Forms.Binding("Text", ds.Clients, "ID")
txtID.DataBindings.Add(db)
db = New System.Windows.Forms.Binding("Text", ds.Clients, "Company")
txtCompany.DataBindings.Add(db)
db = New System.Windows.Forms.Binding("Text", ds.Clients, "Address")
txtAddress.DataBindings.Add(db)

bmCompanyDetails = CType(BindingContext(ds, "Clients"), CurrencyManager)

Adding a new record;

ds.Clients.Clear()
bmCompanyDetails.AddNew()

Some data is entered in the Company and Address bound fields by user and
Save button is pressed to save as below;

Focus()
bmCompanyDetails.EndCurrentEdit()
Row = DirectCast(bmCompanyDetails.Current, DataRowView).Row

If (Row.RowState = DataRowState.Added) Then
' Row.Item(5) = "Test column 5" ' if this line is un-remmed this data is
stored in datatable so update is working
daCompanies.Update(ds.Clients)
End If

The Clients table is an MS Access table with ID set to Random Auto number.

Thanks

Regards
 
So if I understand correctly, the data will update in the underlying row if
you uncomment that line of code out. If you use yourDataSet.HasChanges(),
what does it return (putting it right before the Update call?). Is it that
when you call Update, it doesn't get sent to the DB?
 
Ryan, it was a binding issue which Miha has kindly solved for me in another
thread.

Many Thanks

Regards
 
Back
Top