PC Review


Reply
Thread Tools Rate Thread

About autoincrement

 
 
Tony
Guest
Posts: n/a
 
      5th Jan 2012
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

 
Reply With Quote
 
 
 
 
Jason Keats
Guest
Posts: n/a
 
      5th Jan 2012
Tony wrote:
>
> 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 ?
>


Please read the section called "AutoIncrement Columns":
http://msdn.microsoft.com/en-us/libr...=vs.71%29.aspx

Now do you understand why you should use an AutoIncrementStep of -1 in
your DataSet (and +1 in your database)?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:51 AM.