Solved

ADO query problem

Posted on 2006-11-05
12
1,432 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
12 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 20 total points
Comment Utility
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
Comment Utility
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
Comment Utility
if it's D5 You need Delphi's ADOUpdate

ziolko.
0
 
LVL 6

Assisted Solution

by:wimmeyvaert
wimmeyvaert earned 20 total points
Comment Utility
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:wimmeyvaert
Comment Utility
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:saravananvg
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Forced accept.

Computer101
EE Admin
0
 
LVL 1

Expert Comment

by:Florian1
Comment Utility
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
 
LVL 6

Expert Comment

by:wimmeyvaert
Comment Utility
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

12 Experts available now in Live!

Get 1:1 Help Now