Solved

ADO query problem

Posted on 2006-11-05
12
1,438 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
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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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:wimmeyvaert
ID: 17880106
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
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 26523072
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

773 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