| | |
C# and mycrosoft sql server 2k8?
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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
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.
•
•
Join Date: Aug 2008
Posts: 1,158
Reputation:
Solved Threads: 136
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
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
www.houseshark.net
![]() |
Other Threads in the C# Forum
- Previous Thread: How get mail outlook data and import it to Windows Forms?
- Next Thread: hi help plz
| Thread Tools | Search this Thread |
.net access algorithm animation array bitmap box c# check checkbox client combobox control conversion csharp customactiondata database datagrid datagridview dataset datastructure date/time datetime datetimepicker degrees directrobot dll draganddrop drawing encryption enum excel file filename files form format formbox forms function gdi+ gis gtk hash image input install java label list mandelbrot math mouseclick mp3 mysql native operator outlook2003 packaging path photoshop picturebox pixelinversion pixelminversion post print process programming radians regex remoting richtextbox safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser webcam wfa wia winforms wpf xml






