Solved

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

Posted on 2004-10-17
16
814 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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi,
Haven't You got by chance not Updated Delphi 5? It has a bug.
0
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility
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
Comment Utility
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
Comment Utility

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

Author Comment

by:mece
Comment Utility
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
Comment Utility
didn't you try my code ?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 12

Expert Comment

by:esoftbg
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
danielluyo, I think mece does update of the current record in the dsSSet .... That's all.
0
 
LVL 12

Expert Comment

by:esoftbg
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now