this is a part of the coding you want:
int id = Convert.ToInt32(textbox.Text);
id++;
dataCommand.CommandText = "Select count(*) from <> where [student id] = " + id;
byte check = dataCommand.ExecuteScalar()
if (check > 0)
{
textbox.Text = id.ToString();
}
hope it will help
Becoming Programmer...