G
Guest
Hi,
This thing is giving me the sh** and there must be a
simple way of doing this:
I have a form with several bound controls (textboxes,
combos...).
What i want do do is add a new row. The form should show
all the controls empty, then user can fill in values and
by pressing 'Save', save it to the database.
In the constructor I do this:
CustomersDS.CustomersRow nr = ds1.Customers.NewCustomersRow
();
ds1.EnforceConstraints = false; //without this it'll bomb.
ds1.Customers.AddCustomersRow(nr);
this.BindingContext[ds1, "Customers"].Position =
ds1.Customers.Rows.Count;
In the Save button, this:
if(ds1.HasChanges())
sqlDataAdapter1.Update(ds1.GetChanges()
;
For some reason I can see the newly added values in ds1
before I do the GetChanges(), but if I check the values in
the DataRow of the DataSet created by ds1.GetChanges(),
all fields are empty.
Would be very grateful if anyone can point out what I'm
doing wrong.
Thanks for your help!
Dom
This thing is giving me the sh** and there must be a
simple way of doing this:
I have a form with several bound controls (textboxes,
combos...).
What i want do do is add a new row. The form should show
all the controls empty, then user can fill in values and
by pressing 'Save', save it to the database.
In the constructor I do this:
CustomersDS.CustomersRow nr = ds1.Customers.NewCustomersRow
();
ds1.EnforceConstraints = false; //without this it'll bomb.
ds1.Customers.AddCustomersRow(nr);
this.BindingContext[ds1, "Customers"].Position =
ds1.Customers.Rows.Count;
In the Save button, this:
if(ds1.HasChanges())
sqlDataAdapter1.Update(ds1.GetChanges()

For some reason I can see the newly added values in ds1
before I do the GetChanges(), but if I check the values in
the DataRow of the DataSet created by ds1.GetChanges(),
all fields are empty.
Would be very grateful if anyone can point out what I'm
doing wrong.
Thanks for your help!
Dom