int iJobid = 0;SqlConnection sqlCon = new SqlConnection(""Database=Master;Server=in123;User ID=sa;Password=sa123;");sqlCon.Open();SqlCommand sqlCmd = new SqlCommand();sqlCmd.Connection = sqlCon;sqlCmd.CommandText = "Select Max(EmpID) from EmployeeDetails";iJobid = (int) sqlCmd.ExecuteScalar();sqlCon.Close();if (iJobid > 0)iJobid = iJobid + 1;elseiJobid = 1;txtEmpID.Text = iJobid.ToString();