Click here to Skip to main content
16,021,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to fetch autoincreamented varchar values from sql server 2008 into a textbox in asp.net in pageload event.

suppose, i have a coloumn trn_no, data type varchar. if the 1st value inserted manually in the table, like T100,then how would i get the value T101 in the textbox in pageload.please help me.
Posted

1 solution

You can't, and shouldn't try. The reason is simple: SQL is a Multi user system. If you have two users sitting next to each other, they will both be looking at T101 and expecting that to be the ID of the record they enter. Since you don't want two records with the same number, the autoincrement is not applied until the record is written.
 
Share this answer
 
Comments
Saugata84 21-Jun-12 5:51am    
in this case the admin will insert the record .single person
OriginalGriff 21-Jun-12 5:59am    
Doesn't matter - you still shouldn't do it. Firstly, you can't assume that the admin job will remain small enough for one person (so it is bad practice to write code as is it will) and secondly because why would they admin need to know in advance of entry anyway - they may not commit the change to the DB, and until they do, it isn't set in stone that it is a used reference.

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