Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 1st, 2005, 09:25 AM
Authorized User
 
Join Date: Sep 2005
Location: Kraków, , Poland.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 ?

Reply With Quote
  #2 (permalink)  
Old December 1st, 2005, 09:47 AM
Authorized User
 
Join Date: Sep 2005
Location: Kraków, , Poland.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...

Reply With Quote
  #3 (permalink)  
Old December 3rd, 2005, 11:24 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
Reply With Quote
  #4 (permalink)  
Old December 8th, 2005, 07:26 AM
Authorized User
 
Join Date: Sep 2005
Location: Kraków, , Poland.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...


Reply With Quote
  #5 (permalink)  
Old December 10th, 2005, 11:43 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What scope error would you expect to get?

-Peter
Reply With Quote
  #6 (permalink)  
Old December 12th, 2005, 06:47 PM
Authorized User
 
Join Date: Sep 2005
Location: Kraków, , Poland.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 What scope error would you expect to get?

-Peter
too big int number...
Reply With Quote
  #7 (permalink)  
Old December 15th, 2005, 11:58 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:52 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.