Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Bookmark is not found for dataset



Permlink Replies: 5 - Last Post: Mar 17, 2017 10:25 AM Last Post By: Jeff Overcash (...
Fred Fonar

Posts: 137
Registered: 3/16/00
Bookmark is not found for dataset
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 13, 2016 11:08 AM
I have code that raises exception on getting bookmark so I changed it and GetBookmark returns invalid bookmark:

{=== original =======}
Query2.DisableControls;
BM:=Query2.Bookmark; // value of BM = (216, 147, 254, 6, 0, 0, 0, 0, 0, 0, 0, 0)
Query2.Close;
Query2.Open;
Query2.Bookmark := BM; <- raise error [FireDAC][Comp][DS]-200 Bookmark is not found for dataset [Query2]
Query2.EnableControls;
{======================}

{======================}
Query2.DisableControls;
BM:=Query2.GetBookmark;
Query2.Close;
Query2.Open;
if Query2.BookmarkValid(BM) then <- no valid after this statement
Query2.GotoBookmark(BM);
Query2.EnableControls;
{======================}

Why bookmark mechanism stop working with Delphi 10 and Firebird 2.1?
Clement Doss

Posts: 76
Registered: 3/26/00
Re: Bookmark is not found for dataset
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 13, 2016 1:04 PM   in response to: Fred Fonar in response to: Fred Fonar
Hi,

Bookmarks are valid while the dataset is opened. If you close / open, the bookmark will be invalid.
(Record might have changed or deleted)
To locate a record you should use locate with primary key (or FindKey ).


Why bookmark mechanism stop working with Delphi 10 and Firebird 2.1?

HTH,
Clément
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Bookmark is not found for dataset
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 14, 2016 4:26 AM   in response to: Fred Fonar in response to: Fred Fonar
var
  aBookMark: Integer;
begin
  aBookMark := MyDBGrid.DataSource.DataSet.FieldByName('Fieldname').AsInteger;
  
  //...
 
  MyDBGrid.DataSource.DataSet.Locate('Fieldname', aBookMark, [loCaseInsensitive]);
end;
Carlos Cesar

Posts: 1
Registered: 3/7/08
Re: Bookmark is not found for dataset
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 17, 2017 7:08 AM   in response to: Fred Fonar in response to: Fred Fonar
Hi friend. Try this:

Query2.DisableControls;
BM:=Query2.Bookmark; // value of BM = (216, 147, 254, 6, 0, 0, 0, 0, 0, 0, 0, 0)
Query2.REFRESH;
Query2.Bookmark := BM;
Query2.EnableControls;

I'm using with firedac components and it works.


Fred Fonar wrote:
I have code that raises exception on getting bookmark so I changed it and GetBookmark returns invalid bookmark:

{=== original =======}
Query2.DisableControls;
BM:=Query2.Bookmark; // value of BM = (216, 147, 254, 6, 0, 0, 0, 0, 0, 0, 0, 0)
Query2.Close;
Query2.Open;
Query2.Bookmark := BM; <- raise error [FireDAC][Comp][DS]-200 Bookmark is not found for dataset [Query2]
Query2.EnableControls;
{======================}

{======================}
Query2.DisableControls;
BM:=Query2.GetBookmark;
Query2.Close;
Query2.Open;
if Query2.BookmarkValid(BM) then <- no valid after this statement
Query2.GotoBookmark(BM);
Query2.EnableControls;
{======================}

Why bookmark mechanism stop working with Delphi 10 and Firebird 2.1?
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Bookmark is not found for dataset
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 17, 2017 8:27 AM   in response to: Carlos Cesar in response to: Carlos Cesar
Thanks, Ill try this. But the poster probably found the solution already after one year ;-)
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: Bookmark is not found for dataset
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 17, 2017 10:25 AM   in response to: Carlos Cesar in response to: Carlos Cesar
Just to be clear, bookmarks are documented to only be good for the data set that
was open at the time you got it. Once a dataset is closed and reopened it may
be invalid, may point to a different record or you might get lucky and it still
points to the same record, but that behavior is documented as being right.

Carlos Cesar wrote:
Hi friend. Try this:

Query2.DisableControls;
BM:=Query2.Bookmark; // value of BM = (216, 147, 254, 6, 0, 0, 0, 0, 0, 0, 0, 0)
Query2.REFRESH;
Query2.Bookmark := BM;
Query2.EnableControls;

I'm using with firedac components and it works.


Fred Fonar wrote:
I have code that raises exception on getting bookmark so I changed it and GetBookmark returns invalid bookmark:

{=== original =======}
Query2.DisableControls;
BM:=Query2.Bookmark; // value of BM = (216, 147, 254, 6, 0, 0, 0, 0, 0, 0, 0, 0)
Query2.Close;
Query2.Open;
Query2.Bookmark := BM; <- raise error [FireDAC][Comp][DS]-200 Bookmark is not found for dataset [Query2]
Query2.EnableControls;
{======================}

{======================}
Query2.DisableControls;
BM:=Query2.GetBookmark;
Query2.Close;
Query2.Open;
if Query2.BookmarkValid(BM) then <- no valid after this statement
Query2.GotoBookmark(BM);
Query2.EnableControls;
{======================}

Why bookmark mechanism stop working with Delphi 10 and Firebird 2.1?

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02