Databinding manager

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

I have a form with text boxes bind with dataset of a table like Customer
with a CustomerID field.
I bind the dataset with binding manager and I want to add new record.
I called the AddNew() of the binding manager to add a new record, however, I
need to know the MemberID of the last record and add 1 to it and assigned to
the new record, how do I do that ?
 
Hi Alan,

It is recommended to configure the corresponding DataTable column as
AutoIncrement, but set the initial value to -1 and increment also to -1.
Thus, the IDs of newly added rows will never conflict with the existing
ones. When the changes are propagated back to the database, you always know
that rows with negative IDs are new ones and call the appropriate stored
procedure which would create a new record instead of updating an existing
one.
 
Back
Top