Page 1 of 1
Forcibly fetch remainig rows for each dataset?
Posted: Thu 18 Jan 2007 10:43
by Ludek
Hi, I'm having trouble with TMSConnection and FetchAll=false. I already know, that there's problem with starting transaction with unfetched rows, so I simply want do fetch all already unfetched datasets. Ho can I do it? Can't find any such method, thus I'm using following now:
Code: Select all
for i := 0 to connection.DataSetCount - 1 do begin
if connection.DataSets[i] is TCustomMSDataset then begin
ds := connection.DataSets[i] as TCustomMSDataset;
if not ds.FetchAll then begin
ds.FetchAll := true;
ds.FetchAll := false;
end;
end;
end;
I simple HAVE TO start the transaction, what is the best solution? My solution works, but I don't like it at all

Posted: Thu 18 Jan 2007 14:43
by Jackson
Try to use the following construction:
Code: Select all
var
Bookmark: TBookmark;
begin
...
DataSet.DisableControls;
try
Bookmark := DataSet.GetBookmark;
DataSet.Last;
DataSet.GotoBookmark(Bookmark);
finally
DataSet.EnableControls;
end;
..
instead of:
Code: Select all
...
DataSet.FetchAll := True;
DataSet.FetchAll := False;
...
Posted: Thu 18 Jan 2007 15:36
by Ludek
Ok, it seems to be also good enough. Other question: Would it be enough, if I test "not ds.fetched" instead of "not ds.fetchall"? So that it runs fastest possible... and what about datasets with fetchall = false and no records at all? I had trouble one time, when I tried to gotobookmark to a bookmark from empty dataset (some access violation

)
Next question - do i need a freebookmark or is it superfluous?
In the SDAC code, there's a call to FetchAll of an component, if the fetchall is being set to true. I would like to call it myself, but the component is no public property... Could I try to call it myself or is it somehow dangerous???
Posted: Fri 19 Jan 2007 12:44
by Jackson
> Would it be enough, if I test "not ds.fetched" instead of "not ds.fetchall"?
Yes, it is a good idea to call the TCustomMSDataSet.Fetched function to check if DataSet is already fetched.
> and what about datasets with fetchall = false and no records at all?
As for empty DataSet and the TDataSet.GotoBookmark method, everything should be alright, but if you have any troubles, please let us know.
> do i need a freebookmark or is it superfluous?
Yes, you have to сall TDataSet.FreeBookmark to free an existing bookmark.
> ... Could I try to call it myself or is it somehow dangerous???
We do not recommend you to do so.
Posted: Fri 19 Jan 2007 16:10
by Ludek
Could you please add such method, that fetches all not yet fetched data, to the tcustommsdataset class or some ancestor class? I think, many people using SDAC and fetchall = false would appreciate it. Or even a method for the connection, that simple fetches all data from all open datasets. Or do you have any better solution, how could i start a transaction, if some unfetched records are still pending?? Thanks very much for the answers.
Posted: Mon 22 Jan 2007 14:02
by Jackson
We will add such functionality in the next SDAC version.
Posted: Mon 22 Jan 2007 14:13
by Ludek
Thanks a lot!
Posted: Mon 23 Jul 2007 19:14
by Ludek
I am looking now for this added function in current SDAC3, but I can't find it. what's its name? thanks!
Re: Forcibly fetch remainig rows for each dataset?
Posted: Mon 23 Jul 2007 19:51
by Ludek
or, please, tell me, if I can do following:
instead of
Code: Select all
ds.FetchAll := true;
ds.FetchAll := false;
this code
Code: Select all
TMSAccessUtils.FIRecordSet(ds).FetchAll;
ds.Resync([]);
the first code closes in current sdac3 version the dataset

Posted: Tue 24 Jul 2007 08:14
by Antaeus
The functionality discussed above has not been implemented yet. It will not be implemented in SDAC 3, as SDAC 3 is no more developed.
You should use the solution posted above.
Jackson wrote:
Code: Select all
var
Bookmark: TBookmark;
begin
...
DataSet.DisableControls;
try
Bookmark := DataSet.GetBookmark;
DataSet.Last;
DataSet.GotoBookmark(Bookmark);
finally
DataSet.EnableControls;
end;
..
Posted: Tue 24 Jul 2007 12:51
by Ludek
This solution makes me not happy, because it often changes the position in grid - the selected record remains the same, but after gotobookmark it is the first visible record in grid, or the last, simply the users do not see the same records as before
My solution seems to work fine, is something wrong with it?
Will this function be available in the next SDAC4?
When comes the next release of SDAC4? I can't use the current SDAC4 because of those sloooooooooooooow calculated fields
Thanks much for answer!
Posted: Wed 25 Jul 2007 07:38
by Antaeus
Ludek wrote:My solution seems to work fine, is something wrong with it?
This solution should work, but it does not save the record position in the grid, so it works like the solution we suggested. Moreover, we do not grantee that internal SDAC methods in future releases will be compatible with the current ones. So your solution may stop working in the future.
Ludek wrote:Will this function be available in the next SDAC4?
We will add functionality when dataset open in FetchAll=False mode completes fetching when setting FetchAll to True in the next version of SDAC. It will be SDAC 4.20. SDAC 4.20 will be available in beta very soon.
Ludek wrote:When comes the next release of SDAC4?
The next build of SDAC that solves the problem with lookup fields will be available during one week.
Posted: Wed 25 Jul 2007 08:07
by Ludek
Antaeus wrote:
This solution should work, but it does not save the record position in the grid, so it works like the solution we suggested.
Well, I tried it (I mean my last solution), and it never changed the top visible row in the grid

It only changes the size and the position of the scrollbar thumb - and that is really no problem.
Antaeus wrote:
Moreover, we do not grantee that internal SDAC methods in future releases will be compatible with the current ones. So your solution may stop working in the future.
I understand this. I need it only for the versions without the promised functionality - for versions < 4.20, especially for SDAC3. And, as you said, version 3 is not developed any more, so I don't see any danger.
Antaeus wrote:
SDAC 4.20 will be available in beta very soon.
I just can't wait for it
Thanks a lot!