title: how to get the next autoincrement value in sql
body: <p>I am creating a winform application in c#.and using sql database.</p>
  
  <p>I have one table, <code>employee_master</code>, which has columns like <code>Id, name, address</code> and <code>phone no</code>. <code>Id</code> is auto increment and all other datatypes are <code>varchar</code>.</p>
  
  <p>I am using this code to get the next auto increment value:</p>
  
  <pre><code>string s = "select max(id) as Id from Employee_Master";
  SqlCommand cmd = new SqlCommand(s, obj.con);
  SqlDataReader dr = cmd.ExecuteReader();
  dr.Read();
  int i = Convert.ToInt16(dr["Id"].ToString());
  txtId.Text = (i + 1).ToString();
  </code></pre>
  
  <p>I am displaying on a textBox.</p>
  
  <p>But when last row from table is deleted, still I get that value which is recently deleted in textbox</p>
  
  <p>How should I get the next autoincrement value?</p>