Refresh or Close/Open
Posted: 31.07.2007, 18:30
Could somebody tell me what is the difference between Refresh and Close-Open? Actually i would like to know which is better for ZReadOnlyDataset's refreshing.
This is the official forum of ZeosLib providing support to all ZeosLib users.
https://zeoslib.sourceforge.io/
Are you sure about this? Delphi documentation on ZDataSet.Refresh tells an other story. What's more : Firmos wrote a new feature TZAbstractDataset.RefreshCurrentRow(const RefreshDetails:Boolean) to refresh just one row. (Available in Testing branch only)Well, refresh only reload the current record. Close/open redo the entire query, which reload the entire result set.
I have tried it too. The datas of two separeted record are refreshed in the grid.gto wrote:You're right mdaems! I've tried again, and refresh currently refreshes the entire dataset, just like close-open.
I remember to have tested sometime ago and it only refreshed the current row.. anyway
Hum, the main difference seems that refresh lock the position in the same record while close/open should reset the current record postion to the first.trob wrote:I have tried it too. The datas of two separeted record are refreshed in the grid.gto wrote:You're right mdaems! I've tried again, and refresh currently refreshes the entire dataset, just like close-open.
I remember to have tested sometime ago and it only refreshed the current row.. anyway
So what is the difference?
I know, that when i call, refresh the afterscroll doesn't run bacause of some reason. But after open it run.
So, The difference is not the speed, cpu-work, data transmission, etc. Hm?gto wrote:Hum, the main difference seems that refresh lock the position in the same record while close/open should reset the current record postion to the first.trob wrote:I have tried it too. The datas of two separeted record are refreshed in the grid.gto wrote:You're right mdaems! I've tried again, and refresh currently refreshes the entire dataset, just like close-open.
I remember to have tested sometime ago and it only refreshed the current row.. anyway
So what is the difference?
I know, that when i call, refresh the afterscroll doesn't run bacause of some reason. But after open it run.
Code: Select all
{**
Performs an internal refreshing.
}
procedure TZAbstractRODataset.InternalRefresh;
var
RowNo: Integer;
Found: Boolean;
KeyFields: string;
Temp: TZVariantDynArray;
KeyValues: Variant;
FieldRefs: TObjectDynArray;
OnlyDataFields: Boolean;
begin
FieldRefs := nil;
if Active then
begin
if CurrentRow > 0 then
begin
RowNo := Integer(CurrentRows[CurrentRow - 1]);
if ResultSet.GetRow <> RowNo then
ResultSet.MoveAbsolute(RowNo);
if Properties.Values['KeyFields'] <> '' then
KeyFields := Properties.Values['KeyFields']
else
KeyFields := DefineKeyFields(Fields);
FieldRefs := DefineFields(Self, KeyFields, OnlyDataFields);
SetLength(Temp, Length(FieldRefs));
RetrieveDataFieldsFromResultSet(FieldRefs, ResultSet, Temp);
if Length(FieldRefs) = 1 then
KeyValues := EncodeVariant(Temp[0])
else KeyValues := EncodeVariantArray(Temp);
end
else
begin
KeyFields := '';
KeyValues := Unassigned;
end;
DisableControls;
try
try
FRefreshInProgress := True;
InternalClose;
InternalOpen;
finally
FRefreshInProgress := False;
end;
DoBeforeScroll;
if KeyFields <> '' then
Found := Locate(KeyFields, KeyValues, [])
else Found := False;
finally
EnableControls;
end;
if not Found then
begin
DoBeforeScroll;
DoAfterScroll;
end;
end;
end;