| | |
C# and mycrosoft sql server 2k8?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
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,160
Reputation:
Solved Threads: 137
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 array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop php picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox server sleep socket sql statistics stream string study system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml






