?
Solved

ADO query problem

Posted on 2006-11-05
12
Medium Priority
?
1,464 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
11 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 80 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 80 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 80 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 80 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 80 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
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…
Integration Management Part 2
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

750 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