title: mysql insert max + 1 error
body: <p>I have a win form that contain a data grid, i add rows to it and i want to insert this row in the database but each row has its own ID so i wrote this query and try do do this but with errors especially when try to insert max ID +1 in each row please help me to write this query correctly.</p>
  
  <p>Here is my query:</p>
  
  <pre><code>for (int i = 0; i &lt; dataGridView1.Rows.Count; i++)
  {
      OracleConnection CN = new OracleConnection(ConnectionString);
      string Query = 
             "insert into EMP_HASM_DET " +
             "(MAXID,EMPID,GHYAB,TAGMEE3,GZA) " +
             "  (SELECT 1 + coalesce((SELECT max(MAXID) FROM EMP_HASM_DET)), 1),'" + 
             this.dataGridView1.Rows[i].Cells[0].Value + "','" + 
             this.dataGridView1.Rows[i].Cells[1].Value + "','" + 
             this.dataGridView1.Rows[i].Cells[2].Value + "','" + 
             this.dataGridView1.Rows[i].Cells[3].Value + "'";
      OracleCommand cmd = new OracleCommand(Query, CN);
      CN.Open();
      cmd.ExecuteNonQuery();
      CN.Close();
  }
  </code></pre>