Page 1 of 1

GetBookmark and Record not found !

Posted: Fri 28 Jan 2011 16:08
by Fabrice
Hello,

I use an old procedure to refresh a query without lose current record position :

Code: Select all

procedure RefreshQuery(Query: TDataSet;StorePos:boolean=true);
var
  BookMk: TBookmark;
  OldState:boolean;
begin
 if not (Query is TdxMemData) then
 begin
 
 OldState:=Query.active;
 try
  with Query do
  begin
    //DisableControls;
    try
      if Active and StorePos and not isempty then
      begin
        BookMk := GetBookmark;
      end
      else BookMk := nil;
      try
        Close;
        Open;

        //SetToBookmark(Query, BookMk);

        if BookMknil  then
        begin
         try
            GotoBookmark(BookMk);
         except
         end;
        end;

      finally
        if BookMk  nil then
        begin
          FreeBookmark(BookMk);
        end;
      end;
    finally
      //EnableControls;
    end;
  end;
 except
  Query.active:=OldState;

 end;
 end;
end;

But with IBDAC I got sometime an error "Record not found".
In line "GotoBookmark(BookMk);".

I think the problem come from master/slave relationship which change between :

Code: Select all

        Close;
        Open;

Change TibDatasetOptions.options.detailDelay:=100 seems to work better but that happen is the windows/computer is very very slow ?

Does it exists a better method to refresh a TCustomIBCDataSet without lose current record ? Or what to fix in my procedure RefreshQuery ?

Best regards,

Posted: Tue 01 Feb 2011 08:55
by AndreyZ
Hello,

You can use the TCustomIBCDataSet.Refresh method. It saves the current record position.

Posted: Wed 02 Feb 2011 10:46
by Fabrice
AndreyZ wrote:Hello,

You can use the TCustomIBCDataSet.Refresh method. It saves the current record position.
Hello,

It's seems to work fine.
I haven't seen this method in documentation only Resync and RefreshRecord...

Best regards,

Posted: Thu 03 Feb 2011 07:59
by AndreyZ
It is good to see that this problem was solved. The Refresh method is inherited from the TDataSet class. You can find more information in the Delphi help.