A dataset supports two types of bookmarks:
TBookMark returned by the GetBookmark function and a TBookMarkStr
returned by the Bookmark property. IIRC, the two are not
interchangeable.
BookMarkValid requires a TBookMark and DBGrid.SelectedRows returns a
list of TBookMarkStr's.
--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
My problem is that an exception is thrown when I try to assign a bookmark
returned by DBGrid.SelectedRows to the bookmark property of the dataset.
> Just for curiosity: Why 2 kinds of bookmarks? Why not only one kind?
The string type was introduced later, I assume either because it was
simpler or because the change to reference counted strings in Delphi 2
made it more viable.
I don't know why you are getting an AV. I would try debugging into the
RTL code.
The following example copies the selected rows in a db grid to a list
box.
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
s: string;
begin
if DBGrid1.SelectedRows.Count>0 then
with DBGrid1.DataSource.DataSet do
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
for j := 0 to FieldCount-1 do
begin
if (j>0) then s:=s+', ';
s:=s+Fields[j].AsString;
end;
Listbox1.Items.Add(s);
s:= '';
end;
end;
--
Bill Todd (TeamB)
Thanks for both Marc and Bill