5
Reply

Generate next ID's with prefix 'AE' to label C# to sql

Guruprasad Shreegiri

Guruprasad Shreegiri

Sep 3 2016 3:40 AM
301
If I delete in between one record in master table, next auto generate id gives duplicate value
how to solve this 
 
string empid = "AE000"; 
 
con.Open();
SqlCommand cmd = new SqlCommand("select  Count(REGISTRATION_ID) from CANDIDATE_MASTER", con);
int i = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
i++;
Label1.Text = empid + i.ToString();
 
 
REGISTRATION_ID
AE0002
AE0004
AE0005
AE0006
 
If i execute that code ,label will get the value like 'AE0005'
i want to generate next id like 'AE0007' 

Answers (5)