title: Delete Datagridview rows as well as in my access database vb.net
body: <p>this is my code for loading the data in my database going to my datagrid</p>
  
  <pre><code>Private Sub Records_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Dim connString As String = "Provider=Microsoft.Ace.Oledb.12.0; Data Source=" &amp; My.Application.Info.DirectoryPath.ToString() &amp; "\BackUp\Database3.Accdb;"
          Dim MyConn As OleDbConnection
          Dim da As OleDbDataAdapter
          Dim ds As DataSet
          Dim tables As DataTableCollection
          Dim source1 As New BindingSource
          MyConn = New OleDbConnection
          MyConn.ConnectionString = connString
          ds = New DataSet
          tables = ds.Tables
          da = New OleDbDataAdapter("Select * from [userinfo] ORDER BY ID", MyConn) 'Change items to your database name
          da.Fill(ds, "userinfo") 'Change items to your database name
          Dim cb = New OleDbCommandBuilder(da)
          Dim view As New DataView(tables(0))
          source1.DataSource = view
          DataGridView1.DataSource = view
      End Sub
  </code></pre>
  
  <p>and this is my delete button to delete a selected row in datagrid but the whole table is deleted instead (i know this cause i put it to delete the whole table just to know my sql is working)</p>
  
  <pre><code>Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
      Dim connString As String = "Provider=Microsoft.Ace.Oledb.12.0; Data Source=" &amp; My.Application.Info.DirectoryPath.ToString() &amp; "\BackUp\Database3.Accdb;"
      Dim MyConn As OleDbConnection
      Dim da As OleDbDataAdapter
      Dim ds As DataSet
      Dim tables As DataTableCollection
      Dim source1 As New BindingSource
      Dim row As New Integer
      Try
          MyConn = New OleDbConnection
          MyConn.ConnectionString = connString
          ds = New DataSet
          tables = (ds.Tables)
          da = New OleDbDataAdapter("Delete * from [userinfo]", MyConn)
          da.Fill(ds, "userinfo")
      Catch ex As Exception
          MessageBox.Show(ex.Message)
      End Try
  </code></pre>
  
  <p>i want to delete a selected row in my datagrid. thank you in advance</p>