Page 1 of 1

Edit and post on the last record of a table does not set eof to true

Posted: Thu 13 Mar 2008 09:14
by ghaith
Hey,
I'm using MyDAC 5.20.1.14 with delphi 2006

I have the following code:

Code: Select all

    
        while not Telephone.eof do begin
             Telephone.edit;
             TelephoneLedger_number.asstring:=sender.AsString;
             Telephone.post;
        end;

that seems to get stuck on the last record of the table causing an infinite loop, on other records it just posts and go to the next record as the normal behaviour i suppose
I'm merging from paradox and the same code works there normally..

Is this a problem in myDAC, or is it a new behavior for post?

Posted: Thu 13 Mar 2008 16:23
by Antaeus
You should scroll to the next record after post. Try this code:

Code: Select all

while not Telephone.eof do begin
     Telephone.edit;
     TelephoneLedger_number.asstring:=sender.AsString;
     Telephone.post;
     Telephone.next;
end; 

Posted: Fri 14 Mar 2008 06:51
by ghaith
Hey,
Thanks for the reply,

i have thought of that but there's a problem
if i have for example 3 records in telephone, Post on the first record should get me to the second, a next after it will get me to the third record no?

Posted: Fri 14 Mar 2008 12:42
by Antaeus
Post takes care of applying changes but not of scrolling. You can read more about TDataSet methods such as Edit, Post, Next, Prior, and others in the Delphi help.