RAD Studio |  |

Filtering Records Based On Bookmarks
See Also
Collapse All

ADO datasets support the common dataset feature of using bookmarks to mark and return to specific records. Also like other datasets, ADO datasets let you use filters to limit the available records in the dataset. ADO datasets provide an additional feature that combines these two common dataset features: the ability to filter on a set of records identified by bookmarks.

To filter on a set of bookmarks

1. Use the Bookmark method to mark the records you want to include in the filtered dataset.
2. Call the FilterOnBookmarks method to filter the dataset so that only the bookmarked records appear.

This process is illustrated below:
Copy Code

    procedure TForm1.Button1Click(Sender: TObject);
    var
    BM1, BM2: TBookmarkStr;
    begin
    with ADODataSet1 do begin
    BM1 := Bookmark;
        BMList.Add(Pointer(BM1));
    MoveBy(3);
    BM2 := Bookmark;
        BMList.Add(Pointer(BM2));
        FilterOnBookmarks([BM1, BM2]);
    end;
    end;

Copy Code

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    TBookmarkStr BM1;
    TBookmarkStr BM2;
    BM1 = ADODataSet1->Bookmark;
      BMList->Add(BM1);
    ADODataSet1->MoveBy(3);
    BM2 = ADODataSet1->Bookmark;
      BMList->Add(BM2);
      ADODataSet1->FilterOnBookmarks(ARRAYOFCONST((BM1,BM2)));
    }

Note that the example above also adds the bookmarks to a list object named BMList. This is necessary so that the application can later free the bookmarks when they are no longer needed.

See Also

Connecting an ADO Dataset to a Data Store

Working with Record Sets

Using Batch Updates

Loading Data from and Saving Data to Files

Fetching Records Asynchronously

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!