title: How to delete selected database records from a TDBAdvListView?
body: <p>I am testing out Absolute Database by ComponentAce</p>
  
  <p>I have on my Form a TABSTable, TABSDatabase and a TDataSource and the data is being displayed in a TDBAdvListView, MultiSelect and RowSelect are True. I have only one Table.</p>
  
  <p>When either one or more of the Items in the TDBAdvListView are selected I want to have the Database Delete the selected Records.</p>
  
  <p>I have tried this way in the code below:</p>
  
  <pre><code>procedure TMain.DeleteEntry2Click(Sender: TObject);
  var
    i: Integer;
  begin
    with DBAdvListView1.DataSource.DataSet do
    begin
      for i := DBAdvListView1.Items.Count - 1 downto 0 do begin
      if DBAdvListView1.Items[i].Selected then
      begin
        DBAdvListView1.DataSource.DataSet.GotoBookmark(Pointer(DBAdvListView1.Items[i]));
        DBAdvListView1.DataSource.DataSet.Delete;
        end;
      end;
    end;
  end;
  </code></pre>
  
  <p>This always results in an Error Message:</p>
  
  <pre><code>Cannot retrieve record - Native error: 10026
  </code></pre>
  
  <p>I have very little experience with database programming, what am I doing wrong?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I have added a new field into the database named ID as an integer starting from 0 in the hopes that I can reference them with the Locate method and tried with the code below. This produces no error but will only delete the top record in the ListView and if I select more than one it will delete different records than selected.</p>
  
  <p>My new code:</p>
  
  <pre><code>procedure TMain.DeleteEntry2Click(Sender: TObject);
  var
    i: Integer;
  begin
    with DBAdvListView1.DataSource.DataSet do
    begin
      DBAdvListView1.BeginUpdate;
      First;
      for i := DBAdvListView1.Items.Count - 1 downto 0 do begin
      if DBAdvListView1.Items[i].Selected then
      begin
        if dbTable.Locate('ID',DBAdvListView1.Items[i].Selected,[]) then
        dbTable.Delete;
        Next;
        end;
      end;
    dbTable.Close;
    dbTable.Open;
    DBAdvListView1.EndUpdate;
    end;
  end;
  </code></pre>
  
  <p>The dbTable has to be Closed and Opened to see changes for some strange reason - I have tried Refresh to no avail...</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>// To include Table Structure as requested...</p>
  
  <ul>
  <li>ID integer 0</li>
  <li>Title string 200</li>
  <li>Author string 100</li>
  <li>Date string 20</li>
  <li>Location string 60</li>
  <li>Category string 100</li>
  <li>ISBN-13 string 20</li>
  <li>ISBN-10 string 20</li>
  </ul>
  
  <p>In the Absolute Database Utils directory there is a DatabaseManager.exe which I used to create the actual table with and in here I have also now set a Primary Key of the type:</p>
  
  <p>Type - Primary
  Name - ID</p>
  
  <p>The fields for the Index:</p>
  
  <p>ColumnName - ID
  CaseInsensitive - False
  ASC - True
  MaxIndexSize - 20</p>