 |
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application . |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

December 1st, 2005, 09:25 AM
|
Authorized User
|
|
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Update problem
i have very simple Table in DB with 2 columns: id int PK with identity(,name-varchar(50). I have there 2 rows with some data.
Now i delete last row in DataGridView and then i add new row.
And i have id of second row=3 why ?
|

December 1st, 2005, 09:47 AM
|
Authorized User
|
|
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
now i do in that way:
Code:
DataGridView1.DataSource = lpBases.dataSet.Tables[0];
for (int i=0;i<lpBases.dataSet.Tables[0].Rows.Count;i++)
DataGridView1[0,i].Value = i+1;
but it is not good solution...
|

December 3rd, 2005, 11:24 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Typically, databases that use autoincrementing columns keep track of the autoincrement counter regardless of how many rows or which IDs are still in the table. If you want to always have a sequential ID, you could use a non identity int column and manually generate the ID. However, if you delete a row, you still get a broken sequence. Also, this technique can be problematic depending on how you write your queries and how much activity there is against that table.
- Peter
|

December 8th, 2005, 07:26 AM
|
Authorized User
|
|
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by planoie
Typically, databases that use autoincrementing columns keep track of the autoincrement counter regardless of how many rows or which IDs are still in the table. If you want to always have a sequential ID, you could use a non identity int column and manually generate the ID. However, if you delete a row, you still get a broken sequence. Also, this technique can be problematic depending on how you write your queries and how much activity there is against that table.
-Peter
|
but when i do many delete and add operations it is possible that i will get scope error...
|

December 10th, 2005, 11:43 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
What scope error would you expect to get?
- Peter
|

December 12th, 2005, 06:47 PM
|
Authorized User
|
|
Join Date: Sep 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by planoie
What scope error would you expect to get?
-Peter
|
too big int number...
|

December 15th, 2005, 11:58 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Ok, I see. (That's not a scope error per se, it's a data type limitation).
Sure, if you have a SQL table with an integer field that's used as the primary key (starting at 0 going up) then you are limited to 2,147,483,648 records. If you reach that limit then you'll probably be having other problems more important to address.
- Peter
|
Similar Threads
|
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
Update problem |
aceaceace |
Visual Basic 2005 Basics |
6 |
February 21st, 2007 10:25 PM |
Update Problem |
skwilliams |
Classic ASP Databases |
0 |
December 1st, 2005 11:02 AM |
update problem |
lamdog |
ASP.NET 1.0 and 1.1 Basics |
1 |
March 15th, 2005 11:59 PM |
Update problem |
acko |
SQL Server 2000 |
3 |
June 29th, 2004 01:50 AM |
update problem |
Justine |
Classic ASP Databases |
21 |
May 26th, 2004 04:25 PM |
|
 |