?
Solved

ADO query problem

Posted on 2006-11-05
12
Medium Priority
?
1,454 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 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
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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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