Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends,
I created sql table with studentID column as a autoincreamented column.now I want to show the Id from sql to textbox.Before any insertion of data there is no Id on the table. At that time I want show First value in textbox and then show next autoincremented value from sql table for every insertion.Plase help me how can i do this.
Thanks in advance
Posted

1 solution

Don't.
Stop and think about it.
Why are you showing the value at all? So that people know what value will be assigned to the new record they are creating. But the main reason for using SQL is that it supports multiple users at the same time, so the "next value" won't be the next one - that value may have been used by a different user two hours ago.

That leads to confusion - only show information when it will be correct - which in the case of auto incremented data is only after the record has been inserted correctly.

If you need to give the user the record id, then there is probably something wrong with your data design.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900