title: Delete SQL statement for MSACCESS DB
body: <p>I am attempting to run a delete statement for an MS Access DB and i receive an error of "Index out of Range. Must be non-negative and less than the size of the collection".</p>
  
  <p>Here is my delete button code:</p>
  
  <pre><code>Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
      ' This is our DELETE Statement. To be sure we delete the correct record and not all of   
      ' them.  
      ' We use the WHERE to be sure only that record that the user has selected is deleted.  
      Dim con1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Redirection\fakeout\Desktop\AccessDBs\MovieCatalog.mdb")
      Dim sqldelete As String
      sqldelete = "DELETE * FROM Table1 WHERE ID='" &amp; dgvList.CurrentRow.Cells(7).Value.ToString &amp; "'"
      ' This is our DataAdapter. This executes our SQL Statement above against the Database  
      ' we defined in the Connection String  
      Dim adapter As New OleDbDataAdapter(sqldelete, con1)
      ' Gets the records from the table and fills our adapter with those.  
      Dim dt As New DataTable("Table1")
      adapter.Fill(dt)
      ' Assigns the edited DataSource on the DataGridView and the refreshes the   
      ' view to ensure everything is up to date in real time.  
      dgvList.DataSource = dt
      ' This is a Sub in Module 1 to refresh the DataGridView when information is added,  
      '  updated, or deleted.  
      RefreshDGV()
  End Sub
  </code></pre>
  
  <p>I Open my connection on my form load:</p>
  
  <pre><code>Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      sSql = "SELECT ID, Title, YearofFilm, Description, Field1 FROM Table1"
      LoadDS(sSql)
      FillGrid()
  End Sub
  
  Private Sub LoadDS(ByVal sSQL As String)
      Try
          Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Redirection\fake\Desktop\AccessDBs\MovieCatalog.mdb"
          'Open Connection.
          Dim conn As OleDbConnection = New OleDbConnection(cnString)
  
          'Set the DataAdapter's query.
          da = New OleDbDataAdapter(sSQL, conn)
          ds = New DataSet()
  
          ' Fill the DataSet.
          da.Fill(ds, "Items")
  
          ' Set the source table.
          dtSource = ds.Tables("Items")
      Catch ex As Exception
          MessageBox.Show(ex.Message, "Error...", MessageBoxButtons.OK, MessageBoxIcon.Error)
      End Try
  End Sub
  </code></pre>
  
  <p>How should i combine that in my delete function?</p>