[solved] Problem with Edit moving cursor to EOF

The stable tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.
Post Reply
IbeDBob
Junior Boarder
Junior Boarder
Posts: 47
Joined: 27.05.2010, 21:04

[solved] Problem with Edit moving cursor to EOF

Post by IbeDBob »

Can someone please tell me why this only works one time after the aTbl.Edit. If I rem out the four lines for editing the table it iterates through all 49 records. It seems that the Edit and Post will position the file-cursor at the end of the file as I am only ever getting one record changed and it quits with the EOF.

I am using D5, Zeos-6 and SQLite3. I even tried grabbing the Auto-inc before the edit and then a Locate after it, but it still quits after the edit.

Thanks for anything you can suggest, but this has been driving me nuts all afternoon. I keep thinking it is something stupid I have done, but I cannot find it. :)

I have done some more research and if instead of .First, .Next and .EOF, I use .Last, .Prior and .BOF, it sits there forever in a loop as it never moves from the last position in the database.

I know I am using v6 and this is the v7 forum, but there seems to be little action on v6 forum and I need help to figure out how to resolve this issue. I can't use an SQL Query as there is nothing in the existing file that I can key ( WHERE ??? = ) the edits to.

Code: Select all

aTbl.First;                            // Test DB has 49 records
while not aTbl.EOF do
begin
  for i := 0 to lbCt.Items.Count-1 do  // Currently only two items in the list
  begin                                // and only the second makes a match
    aMatch := False;                   // which then forces the edit
    CtStr := lbCt.Items[i]);
    case InOut.ItemIndex of
      0: aMatch := aTbl.FieldByName(fld_A).AsString = CtStr;
      1: aMatch := aTbl.FieldByName(fld_B).AsString = CtStr;
      2: aMatch := (aTbl.FieldByName(fld_A).AsString = CtStr) or
                   (aTbl.FieldByName(fld_B).AsString = CtStr);
      3: aMatch := (aTbl.FieldByName(fld_A).AsString = CtStr) and
                   (aTbl.FieldByName(fld_B).AsString = CtStr);
    end;
    if aMatch then
    begin
      aTbl.Edit; 
      aTbl.FieldByName('Account').AsString := lbCt.Items[i];
      aTbl.FieldByName('Folder').AsString := lbCt.Items[i];
      aTbl.Post;
    end;
  end;
  aTbl.Next;
end;
Thanks

Dyslexic Bob
IbeDBob
Junior Boarder
Junior Boarder
Posts: 47
Joined: 27.05.2010, 21:04

Post by IbeDBob »

OK, problem solved with thanks to another forum. I had a Sequence set in the Table and that was conflicting with one of the updating fields. DUH. I knew it had to be me!! LOL

This Zeos stuff is proving to be very robust. Only used it for a week or so, but am impressed.
Thanks

Dyslexic Bob
Post Reply