title: How to delete and clear the datagridview rows in vb 2010
body: <p>I am developing a Point of Sale System in VB and using access as RDBMS. Everything went well however when it came to deletion i got stuck. <strong>I want to clear all the rows from the datagridview and want to delete it from database also.</strong> The new datagridview will store new items and i am sending that new data to print.I tried the below codes but all in vain.</p>
  
  <pre><code>     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
          For i As Integer = 0 To SProductDataGridView.RowCount
               SProductDataGridView.Rows.Remove(SProductDataGridView.Rows(0))
           Next
  
       End Sub
  </code></pre>
  
  <p><strong>2nd Try</strong> </p>
  
  <pre><code>For i As Integer = 0 To SProductDataGridView.RowCount -1 
            ProductTableAdapter.DeleteProduct(IDTextBox.Text)
            ProductTableAdapter.Fill(MyDS.product)
            ProductTableAdapter.Dispose()
       Next
  </code></pre>
  
  <p><strong>Note :</strong> <code>gridview.rows.clear() + gridview.ds</code> = nothing , i tried that butgridview.rows.clear() doesn't work and gridview.ds = nothing just clear the gridview and is not deleting data from access database.</p>