Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,I am trying to solve one query please help me to find out it.....
I want to auto generate the values which are stored in table from my database.i want to show that auto generated value in textbox by cliking button it will appear in textbox as textbox value.....
ex.last value is E185 and the next value should be show in textbox as textbox value i.e.E186
Posted

1 solution

Simply you take the Last inserted code from your database.
Query : SELECT TOP 1 EmpCode FROM tblEmployee ORDER BY EmpId DESC

This will give you the latest Emp Code.

Now you may split the Code
int iEmpCodeNo = Convert.ToInt(EmpCode.Substring(1));

This will give you the EmpCodeNo. Now increment 1 with this and add the 'E'
string NewEmpCode = "E" + (iEmpCodeNo + 1).ToString();

This will give you the latest code. You may simply bind this in your text box.
 
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