Databinding manager

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 ?
 
D

Dmitriy Lapshin [C# / .NET MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top