Link to home
Start Free TrialLog in
Avatar of andrewyu
andrewyu

asked on

TSQLClientDataSet Eof

After I do TSQLClientDataSet.SaveToFile, Eof is true after LoadFromFile even the XML file have data content inside.

What seems to be the problem ?

Andrew
ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andrewyu
andrewyu

ASKER

What do you meant by that ?
?? I am assuming you have some experience with datasets...

If the dataset is at EOF, then the dataset's cursor (current record) is located AFTER the last record in the dataset. The cause of this is most likely the SaveToFile performing something like:

DataSet.First;
while not(DataSet.Eof) do
begin
  ... export the record
  Dataset.Next;
end;

At the end of this, the DataSet's cursor is at the EOF marker. Meaning, you need to call TSQLClientDataSet.First in order to reset the cursor to the first record again.



Russell
So, you suggest to call DataSet.First; before import and and export first. am i correct ?

Yes on the after part...
As to the before part, I would imagine that the person (who wrote the export routine) already considered this and is doing it already. The easiest way to tell is to call the DataSet's .Last method, run the SaveToFile, and confirm that all the data is written out.

Russell

Btw, I didnt mean to infer that calling .First both before AND after would cause any problem. While it may be unnecessary calling it before the export, it should not hurt anything either.