andrewyu
asked on
TSQLClientDataSet Eof
After I do TSQLClientDataSet.SaveToFi le, Eof is true after LoadFromFile even the XML file have data content inside.
What seems to be the problem ?
Andrew
What seems to be the problem ?
Andrew
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
?? 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
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
ASKER
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.
ASKER