Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all. In my app i've a small data entry form where the employee enters his details.Now i need to save these details into a table which has an EmpID column as primary key.Now i want to auto generate this EmpID value dynamically.For this scenario i wrote a stored procedure in which i'll retrieve the maximum value of EmpID and i'll increment that value and i'll insert that increment value as EmpID value.Other than this approach is any other way for this scenario because in my app now i need to display only those entered Employee values in another values.So for this scenario i need to store the EmpID value in session and i'll retrieve the Employee details through EmpID value from the session.So,please guide me for this scenario.

Thanks in Advance.
Posted
Comments
PIEBALDconsult 29-Jan-13 10:10am    
You don't do it in ASP.net; you do it in the backend code. You need to think in layers.

"retrieve the maximum value of EmpID and i'll increment"

Bad idea.

1 solution

You can use IDENTITY (Property)[^] in PK column, which is intended for generating sequential values.
Also you can use NEWID()[^] or NEWSEQUENTIALID()[^] functions for getting the Default value of PK column.
 
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