Solved

TAdoDataSet "Either bof or eof is true, ..." Error! Why ? How to solve ?

Posted on 2004-10-17
16
853 Views
Last Modified: 2010-04-05
Hi to all,

When below code executes in my program,
*************************
dsSine.Filter := 'SineID=NULL';
dsSine.Filtered := true;

dsSine.First;
for i := 1 to dsSine.RecordCount do
  dsSSet.Edit;
  dsSSet['SS'] := dsSSet['SS'] - dsSine['Mict'];
  dsSSet.Post;
end;

dsSine.Filtered := false;
********************
it gives error "Either BOF or EOF is true or the current record has been deleted,Requested operation requires a current record" at the last line (posting).I'm using delphi 7, with installed update. I recompile, rebuild my code after update but nothing changes. I search internet, found some solutions but all for delphi 5 and says "update your delphi".

When i put "try except" code into the loop, it does not post first and last changes to dataset.

(Database is key indexed with autoincrement number field.)

Any ideas ? I need a solution...

Thanx...
0
Comment
Question by:mece
  • 7
  • 4
  • 2
  • +3
16 Comments
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12334459
try something like:

dsSine.Filter := 'SineID=NULL';
dsSine.Filtered := true;

dsSine.First;
while not (dsSine.EOF) do
  dsSSet.Edit;
  dsSSet['SS'] := dsSSet['SS'] - dsSine['Mict'];
  dsSSet.Next //this should automatically call the Post method
end;

dsSine.Filtered := false;
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 125 total points
ID: 12334477
Try this:

  dsSine.Filter := 'SineID=NULL';
  dsSine.Filtered := true;
  try
    if (dsSine.RecordCount>0) then
    begin
      dsSine.First;
      while not dsSine.EOF do
      begin
        dsSSet.Edit;
        dsSSet['SS'] := dsSSet['SS'] - dsSine['Mict'];
        dsSSet.Post;
        dsSine.Next;
      end;
    end;
  finally
    dsSine.Filtered := false;
  end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 12334522
Hi,
Haven't You got by chance not Updated Delphi 5? It has a bug.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12334822
Update your MDAC components to version 2.8 from Microsoft's site. If you are using Delphi 7 with update to 7.1 this should help:
http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&displaylang=en
0
 

Author Comment

by:mece
ID: 12338894
I update mdac to 2.8 but it gives error again.

i tried  BlackTigerX's code, it didnt work. I will try esoftbg's code.
0
 
LVL 17

Expert Comment

by:mokule
ID: 12339454

If this is a case I was writing about You should update Delphi.
0
 

Author Comment

by:mece
ID: 12340106
how can i update delphi ? mokule

I installed delphi 7 update 1 pack. I updated mdac 2.8.
I read about updating delphi 5 at internet but i use delphi 7. What can i do ? This is a bug and i dont know how to fix it
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12340239
didn't you try my code ?
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12340399
mece's code is obviously a wrong one:
//........
dsSine.First;
for i := 1 to dsSine.RecordCount do // THIS LOOP AFFECTS ONLY NEXT ROW AND YOU HAVE MANY TIMES dsSSet.Edit; ????
  dsSSet.Edit;
  dsSSet['SS'] := dsSSet['SS'] - dsSine['Mict'];
  dsSSet.Post;
end;


BlackTigerX,s code is obviously a wrong one:
//........
while not (dsSine.EOF) do              // THIS LOOP AFFECTS ONLY NEXT ROW AND YOU HAVE MANY TIMES dsSSet.Edit; ????
  dsSSet.Edit;
  dsSSet['SS'] := dsSSet['SS'] - dsSine['Mict'];
  dsSSet.Next //this should automatically call the Post method
end;

Only my code is a correct one ....
0
 

Author Comment

by:mece
ID: 12340705
I^'m tring your code but something interesting here that when i run it, only one dataset is updated and at the second loop (next is called), eof becomes true. But i have 5 records in dataset !!!
0
 
LVL 3

Expert Comment

by:danielluyo
ID: 12340834
toy have 2 dataset dsSET and dsSINE.
You are looping  dsSine but updating dsSET?? is that correct??

dsSine and dsSET could have a different number of records, after the filter is applied maybe there is something wrong with the logic
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12340919
You may use a ADOqueryCount to get the correct RecordCount by next code:

  dsSine.Filter := 'SineID=NULL';
  dsSine.Filtered := true;
  try
    ADOqueryCount.Active := False;
    ADOqueryCount.SQL.Text := ' SELECT COUNT(*) as FILTERED_CONUT FROM Sine WHERE SineID=NULL';
    ADOqueryCount.Active := True;
    if (ADOqueryCount.FieldByName('FILTERED_CONUT').AsInteger>0) then
    begin
      dsSine.First;
      while not dsSine.EOF do
      begin
        dsSSet.Edit;
        dsSSet['SS'] := dsSSet['SS'] - dsSine['Mict'];
        dsSSet.Post;
        dsSine.Next;
      end;
    end;
  finally
    dsSine.Filtered := False;
  end;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12340943
danielluyo, I think mece does update of the current record in the dsSSet .... That's all.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12351402
Hi mece,
I am trying to understand this senetnce:
> I^'m tring your code but something interesting here that when i run it, only one dataset is updated and at the second loop (next is called), eof becomes true. But i have 5 records in dataset !!!

Only one dataset (dsSSet) is updated because:
        dsSSet.Edit;
        //........;
        dsSSet.Post;
The loop is for dsSine, but the update is for dsSSet.

May be
  dsSine.Filter := 'SineID=NULL';
reduces the count of records from 5 to 2 that satisfy the condition 'SineID=NULL';
i.e. only into 2 records the field SineID is NULL
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12351463
There is no loop about dsSSet so my code updates the current record of dsSSet. Only you know which is this record, i.e. on every run of above code, the current record may be different or same: it depends on the user of application ....
May be your code in the question is totally wrong and I can not understand it correctly ?
0
 

Author Comment

by:mece
ID: 12356107
hi esoftbg

it gives same error at the last loop but at this time, it saves changes to database

Thanx for help

MeCeX
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 57
Printing problem 2 92
Convert a string into a TDateTime 5 60
Not able to call Delphi XE10 dll function from Delphi 6.0 4 26
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question