title: Update query with Autonumber field in ms access from VB.NET
body: <p>How i update data with Autonumber field in ms access from VB.NET. I try this code for update. But nothing change.</p>
  
  <pre><code>Private Sub BTNUPDATE_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTNUPDATE.Click
      Try
          getConnect()
  
          Dim strSQL As String
          Dim iCount As Integer
          strSQL = " UPDATE DEPARTMENT SET [DEPART]=@DEPART,[DEP_DSCRPTN]=@DEP_DSCRPTN WHERE [DEP_ID] = @DEP_ID"
          Dim cmd As New OleDb.OleDbCommand(strSQL, Conn)
          cmd.Parameters.AddWithValue("@DEP_ID", CInt(DEPID.Text))
          cmd.Parameters.AddWithValue("@DEPART", CMBDEPT.Text)
          cmd.Parameters.AddWithValue("@DEP_DSCRPTN", TXTDESC.Text)
          Conn.Open()
          iCount = cmd.ExecuteNonQuery()
          Conn.Close()
          If iCount &gt; 0 Then
              MessageBox.Show("Record Updated Successfully!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information)
              If Windows.Forms.DialogResult.OK Then
                  BTNCLEAR.PerformClick()
              End If
          Else
              MsgBox("No record was inserted")
          End If
  
      Catch ex As Exception
          MsgBox("ERROR: " + ex.Message, MsgBoxStyle.Information, "Update")
      Finally
  
          BTNCLEAR.PerformClick()
      End Try
  
  End Sub
  </code></pre>
  
  <p>In database <code>DEP_ID</code> is Autonumber. and <code>DEPID</code> is a label box to retrieve <code>DEP_ID</code>. Actually the label is hidden in the form. I try the above code. But nothing change in database. Please check my code and correct me.</p>