title: How to delete a selected row from datagridview and database
body: <p>The idea is that the row that is selected when deleted gets removed from datagridview, database and then datagridview gets refreshed. I assume it has to be done with SQL but how would you link that sqlcommand of type text with a delete code with that particular row?
  The database consists of one single table and the datagrid is bound to it.</p>
  
  <p>Delete button:</p>
  
  <pre><code>private void btnBookRecord_Click(object sender, EventArgs e)
  {
      if (this.BooksGrid.SelectedRows.Count &gt; 0)
      {
          foreach (DataGridViewRow dgvrCurrent in BooksGrid.SelectedRows)
          {
              if (dgvrCurrent == BooksGrid.CurrentRow)
              {
                  BooksGrid.CurrentCell = null;
              }
  
              // Delete row code here
          }
      }
  }
  </code></pre>