Click here to Skip to main content
16,012,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is is possible to get new values for Id (IDENTITY) before/while inserting data in a table on Button Submit - CODE level C#?
Posted

You can get the next value of the Id from SQL Server, see, for instance get the next value of identity[^] . if you make the (somewhat unsafe) assumption that only your code deals with the table than you may record IDENT_CURR and IDENT_INCR values in order to compute next ones.
 
Share this answer
 
Use random function to generate the random numbur in C#
 
Share this answer
 
Comments
CPallini 21-Jan-14 8:29am    
That would produce quite different values. :-)
SELECT IDENT_CURRENT('TableName') gives you the current Id(IDENTITY).
 
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