connect.Open();
SqlCommand cmd = new SqlCommand("SELECT empID FROM emp WHERE empID=(SELECT max(empID) FROM emp);");
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
System.Data.SqlClient.SqlDataReader dr = null;
dr = cmd.ExecuteReader();
int age = Convert.ToInt32(textBox4.Text);
int id = Convert.ToInt32(dr["empID"].ToString());
textBox1.Text = (id + 1).ToString();
string save = "INSERT INTO emp (empID, empLName, empFName, empAge, empGender, empAddress, empEmail, empUser, empPass, empType) values('"
+ id + "','" + textBox2.Text + "','" + textBox3.Text + "','" + age + "','" + gender + "','" + textBox5.Text + "','"
+ textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + postn + "')";
SqlCommand cmdsave = new SqlCommand(save, connect);
cmdsave.ExecuteNonQuery();
MessageBox.Show("Saved!");
connect.Close();
I can add employee when manually putting empID on my form, but I want it to be automatically added on my database by adding 1 on it.