title: How to Get the Auto-Increment Values after Insert Statement i n vb.net 2010
body: <p>I am new in vb.net and MySQL database, i am to far from what i am practicing but suddenly i'm stack in getting the value of the current data of the attribute from my table which is auto increment after inserting my query. Here is my code:</p>
  
  <pre><code>Imports MySql.Data.MySqlClient
  
  Try
      Dim dbcon As New MySqlConnection
      Public dbcom As New MySqlCommand
      Public sql As String
      Dim theID As String ' this is the variable where the auto increment ID will be stored.
          dbcon.ConnectionString = "server=localhost; uid=root; pwd=; database=test;"
          dbcon.Open()
          sql = "insert into tableThis values('" &amp; Name &amp; "');" 'this will produced an auto increment value
          dbcom = New MySqlCommand(sql, dbcon)
          dbcom.ExecuteNonQuery()
          MsgBox("Added!Your ID IS: ", &amp; theID) ' the auto increment ID will be display
      Catch ex As Exception
          MsgBox("Error!")
          Exit Sub
  End Try
  </code></pre>
  
  <p>**
      my table is:</p>
  
  <pre><code>-------------------------------------
  --         tableThis             ----
  -------------------------------------
  -- id   -- INTEGER (AUTO_INCREMENT) -
  -- name -- CHAR                     -
  -------------------------------------
  </code></pre>
  
  <p>Thanks! Sorry for my bad English. </p>