C# and mycrosoft sql server 2k8?

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 3
Reputation: rubentan is an unknown quantity at this point 
Solved Threads: 0
rubentan rubentan is offline Offline
Newbie Poster

C# and mycrosoft sql server 2k8?

 
0
  #1
Nov 11th, 2008
hi guys, im using microsoft c# along with sql server 2k8 to build my database software, i have 2 problems..

1st is i cant seem to make an incrementing primary key that doesnt start with 1?
i wanted to make my primary key start from 00001 then increment it by 1 but it only allows me to start from 1 and increment by 1.

2nd problem is, when i delete rows in my database using my c# program, it works but when i add new rows, it still remembers the primary key of the row i deleted then it skips the primary key and uses the next number..
Example if this is when i delete a row with primary key of 4. then add a new row, it automatically creates a row with primary key of 5 instead of 4. can i fix this? thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: C# and mycrosoft sql server 2k8?

 
0
  #2
Nov 11th, 2008
If you have an auto incrementing number, you've just described exactly what it is supposed to do, it does not reuse numbers. If you want it to fill in the holes, then you would need to not use an auto increment, and do a routine that works out the holes in your numbers list to find which numbers it can put in.

As for the key being 000001, that comes down to formatting.

Neither of these is specific to c# or SQL 2008
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: C# and mycrosoft sql server 2k8?

 
0
  #3
Nov 11th, 2008
Sivak, your post has nothing to do with this thread.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: C# and mycrosoft sql server 2k8?

 
0
  #4
Nov 11th, 2008
set identity seed to be able to change the 1 to a different number

the padding with 0's is formatting, do it code side or in query, not store numbers in a database like that
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC