About autoincrement

T

Tony

Hello!

I read a book and this must be wrong. It says "Earlier.,when I mentioned
some potential problems that can arise from working with DataRelations that
are not associated with ForeignKeyConstrants, I covered a scenario involving
auto-increment values. the worst-case portion of the scenario occurs when
the placeholder values that ADO.NET generates for auto-increment column
correspond to rows that already exist within the database".

I mean the following if you have a DataTable and you have auto-increment on
the primary key these
values that are generated by ADO.NET are separate from those that the
database generate when the row should be inserted into the database.

Assume we have a DataTable that has just these two DataColumns ID and Name.
We use auto-increment on the ID and we add one row to the DataTable that now
had a value of 5 because we had 4 old rows in the DataTable. Normally I use
seed and step of -1 but this example is just to understand how it works.

When this row is added to the database that also of course use
auto-increment it will just treat the ID as an placeholder and increment the
built in ID in the DataBase by one.

So as a summary the autoincrement that ADO.NET uses are completely separate
from this autoincrement that the database uses

Do you agrre with me ?

//Tony
 

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