Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-10-17
16
Medium Priority
?
945 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

705 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