Solved

ADO query problem

Posted on 2006-11-05
12
1,450 Views
Last Modified: 2010-02-09
Hi,
i m using delphi 5 and access database on backend. i m using ADO component for accessing the database,
I m getting the error msg "either BOF or EOF found, or the current record is deleted". I m using the Provider 'Microsoft.Jet.OLEDB.4.0'.

Part of my code is

procedure mainp;
begin
       ExePath:='C:\DBases\'+'*.mdb';
       Hd:=FindFirstFile(Pchar(Exepath),P);

       Flname:=P.cFileName;
       ADOConnection1.close;
       with ADOConnection1 do
         Connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source='+Flname+';Mode=Share Deny None;';
       proc1;

       while FindNextFile(Hd,P) do
       begin
           Flname:=P.cFileName;
               ADOConnection1.close;
               with ADOConnection1 do
                 Connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source='+Flname+';Mode=Share Deny None;';
               proc1;
           end;
       end;
end;


procedure TForm1.proc2;
Var Temp,cmp:string;
i,j:integer;
begin
   ADOQuery1.active:=false;
   ADOQuery1.SQL.Clear;
   ADOQuery1.SQL.text:='Select name from table1;
   ADOQuery1.active:=true;
 
  for j:=0 to ADOQuery1.RecordCount-1 do
  begin
      Temp:=ADOQuery1.Fields[0].AsString;
      if temp<>'' then
      begin

            with ADOQuery2 do
            begin

              try
               active:=False;
               Temp:='Update table1 set name="'+temp+'"';
               SQL.Clear;
               SQL.text:=Temp;
               ExecSQL;
              finally
                active:=False;
              end;

            end;
        ADOQuery1.Next;
   end;
  ADOQuery1.Active:=false;
end;

Can anybody help

thanks
0
Comment
Question by:Asmitagoyal
[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
12 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 20 total points
ID: 17879263
well, don't know which delphi version u use but see

http://info.borland.com/devsupport/delphi/mdac26.html

meikl ;-)
0
 
LVL 11

Assisted Solution

by:calinutz
calinutz earned 20 total points
ID: 17879393
Instead of statements like this:

"for j:=0 to ADOQuery1.RecordCount-1 do"

use

ADOQuery1.First;
while not ADOQuery1.Eof do
begin
...
ADOQuery1.Next;
end

You probabely reach the end of the dataset and try to call the next record (which does not exist)

Regards
0
 
LVL 21

Assisted Solution

by:ziolko
ziolko earned 20 total points
ID: 17879863
if it's D5 You need Delphi's ADOUpdate

ziolko.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Assisted Solution

by:wimmeyvaert
wimmeyvaert earned 20 total points
ID: 17880093
Yes, it is definitely an update-issue :
I had this problem also.
Fixed with downloading and instyalling following updates :
http://info.borland.com/devsupport/delphi/downloads/dado501readme.html

http://info.borland.com/devsupport/delphi/downloads/dent501readme.html

http://info.borland.com/devsupport/delphi/mdac26.html

Best regards,

The Mayor.
0
 
LVL 6

Expert Comment

by:saravananvg
ID: 17912948
Hello Sir,

   Try the following

procedure TForm1.proc2;
Var Temp,cmp:string;
i,j:integer;
begin
   ADOQuery1.Close;
   ADOQuery1.SQL.Clear;
   ADOQuery1.SQL.Add('Select name from table1);
   ADOQuery1.Open;
  While not ADOQuery1.Eof do
  begin
      Temp:=ADOQuery1.Fields[0].AsString;
      if temp<>'' then
      begin
            with ADOQuery2 do
            begin
              try
               Close;
               Temp:='Update table1 set name="'+temp+'"';
               SQL.Clear;
               SQL.Add(Temp);
               ExecSQL;
              finally
              //  active:=False;
              end;
            end;
     end;
     ADOQuery1.Next;
end;

with regards,
padmaja.

with regards,
padmaja.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 17913445
I think the cause of your problem is not the code you have been written, but has to do with the delphi updates.

Although it is true that for looping a complete recordset, you better use

while not ADOQuery1.Eof do
begin
    // Your actions here.
    ADOQuery1.Next;
end;

instead of

for j:=0 to ADOQuery1.RecordCount-1 do
begin
    // Your actions here.
end;
0
 
LVL 3

Assisted Solution

by:Ronald Buster
Ronald Buster earned 20 total points
ID: 17929458
why don't you use the following place an ADOCommand on your form instead of an ADOQuery :

procedure mainp;

   procedure ExecuteProc;
   begin
      ADOCommand.Connection := ADOConnection1;
      ADOCommand.CommandText := 'update [table1] set [name] = "'+temp+'" where ( [name] is null ) or ( [name] = "" )
      ADOCommand.Execute;
   end;

begin
       ExePath:='C:\DBases\'+'*.mdb';
       Hd:=FindFirstFile(Pchar(Exepath),P);

       Flname:=P.cFileName;

      with ADOConnection1 do
         Connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source='+Flname+';Mode=Share Deny None;';
 
      ADOConnection1.Open;
     
       ExecuteProc;

       ADOConnection1.close;


       while FindNextFile(Hd,P) do
       begin
           Flname:=P.cFileName;

              with ADOConnection1 do
                 Connectionstring:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source='+Flname+';Mode=Share Deny None;';
               
               ADOConnection1.Open;
               
               ExecuteProc;

               ADOConnection1.Close;
           end;
       end;
end;


0
 
LVL 1

Expert Comment

by:Computer101
ID: 21133161
Forced accept.

Computer101
EE Admin
0
 
LVL 1

Expert Comment

by:Florian1
ID: 26521819
The metioned links are no more available. Does someone have an idea where to get the first ADO update for Delphi5 named d5adoupdate.exe ?

Would be great if somebody could help me. Every Google hit points to hte outdated link.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

717 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