Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
6
Answers
Error in Auto increment ID in C#?
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Sakthis
10y
1.5k
1
Reply
I am success while increment the id 1 to 10 after that it can't increment, i mean after the 10 while i increment the id it comes 10 only again and again and stored multiple 10 in sql table? i dont know how to resolve it can anyone?
Here enclosed my code :
private void btnAutoID_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection("Data Source=sakthi\\sqlexpress; Initial Catalog=LoginDetails; Integrated Security=True;");
SqlCommand sqlcmd = new SqlCommand("select isnull(max(empcode), 0) from emp", sqlcon);
{
sqlcon.Open();
object obj = sqlcmd.ExecuteScalar();
sqlcon.Close();
txtEmpCode.Text = (int.Parse(obj.ToString()) + 1).ToString();
}
}
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
C# BeginInvoke and Callback
c#.Net, send mail with Infopath form