title: DataGridview and MySQL Deleting rows with Checkbox
body: <p>I have a Datagridview and I want to delete a row in my MySQL database.</p>
  
  <p>I have some code but I get an error, it says ID is null. My ID is a string which is the value of the ID where the columns are checked. My first column "column 0" is a checkbox column</p>
  
  <p>Here is the code:</p>
  
  <p>Feel free to ask specific questions if you don't understand what I am asking.</p>
  
  <pre><code>Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)        Handles Button2.Click
  Dim RowsToDelete As New List(Of DataGridViewRow)
  
  
  
  
  Try
  For Each row As DataGridViewRow In DataGridView1.Rows
  
  If row.Cells(0).Value = True Then
  
  DeleteRow(row.Cells(1).Value)
  RowsToDelete.Add(row)
  End If
  Next
  Catch ex As Exception
  MessageBox.Show(ex.ToString)
  End Try
  
  
  For Each rowtodelete In RowsToDelete
  DataGridView1.Rows.Remove(rowtodelete)
  
  next       
  
  
  End Sub
  
  Private Sub DeleteRow(ByVal ID As Integer)
  Dim MySQLCon As New MySqlConnection
  Dim ConnectionString As String = "server=localhost;user id=root;password=;database=business elements"
  
  MySQLCon.ConnectionString = ConnectionString
  Dim CMD As MySqlCommand
  MySQLCon.Open()
  Try
  CMD.Connection = MySQLCon
  CMD.CommandText = "DELETE FROM `users` WHERE `ID` = " &amp; ID
  
  Catch ex As Exception
  
  End Try
  
  MySQLCon.Close()
  MySQLCon.Dispose()
  End Sub
  </code></pre>
  
  <p></p>