Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADOQuery EOF crashes program! 1

Status
Not open for further replies.

jcfrasco

IS-IT--Management
Apr 27, 2001
89
US
First, I want to thank everyone that has helped me on other prblems with this program. Now I'll get to the next problem I'm having and that is with the ADOQuery recordsets. When I set the SQL in a query and open it, and it returns and empty recordset because it didn't find any records meeting the search requirments, I get and error when I try to close the ADOQuery to change the SQL to search for something else. The error says "Project WorkOrdeer.exe raised exception class EOleException with message 'Either BOF or EOF is true, or the current record has been deleted. Requested operation requires a current record'.Process stopped." I also get this message when I increment through a recordset until EOF equals true. I need to know haw to trap this error and allow me to close the query without crashing the program.

I appreciate all the help I have received so far and will appreciate any additional information anyone else can provide.

jcfrasco
 
It would be helpful if you posted a bit of the actual code you are using. It is difficult to guess what may be going wrong from the description you provided.
 
The actual code looks like this:

procedure TfrmTools_Main.txtSNChange(Sender: TObject);

Begin
if txtSN.text <> ” “ then
Begin
//adoqTools_Main is the name of the ADOQuery object.
//The connection is to an SQL 2000 Server.
adoqTools_Main.close;
adoqTools_Main.SQL.Clear;
adoqTools_Main.Sql.Add('SELECT ToolID, Name, PN, SN, FROM tbl_Tools_Main');
adoqTools_Main.Sql.Add('WHERE SN like ' + '''' + UpperCase(txtSN.Text) + '%' + '''');
adoqTools_Main.open;
End

Else
Begin
adoqTools_Main.close;
adoqTools_Main.SQL.Clear;
adoqTools_Main.Sql.Add('SELECT ToolID, Name, PN, SN, FROM tbl_Tools_Main');
adoqTools_Main.Sql.Add('WHERE ToolID <> 0 ORDER BY ToolID');
adoqTools_Main.open;
End

end;

This works perfectly until the user types in a character that causes the recordset to return empty or at EOF. Once this happens and the program tries to close the query to change the SQL, an error appears saying “Project WorkOrder.exe raised exception class EOleException with message ‘Either BOF or EOF is true, or the current record has been deleted. Requested operation requires a current record. Process Stopped.”. The error also appears when I increment through a recordset and reach EOF and try to close the query.

I appreciate any assistance with this problem.

jcfrasco
 
I can't reproduce your symptoms using the code provided.

I did change the &quot;fancy quotes&quot; in
Code:
  if txtSN.text <> ” “ then
to
Code:
 if txtSN.text <> '' then
But other than that, it works perfectly fine no matter what is entered into txtSN.

What does the program do with the data after fetching it and before the user makes a different selection?
 
I gave Zathras a star. I've never taken the time to actually load someone else's code up and set up a database to test it. Effort above and beyond. Good job.

Does the program actually halt in this section of code? On what line does it stop?

If the problem is tied to EOF, can you move to First or BOF before closing the query? Brian
&quot;There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group.&quot; - tag line I stole
 

Sorry for not responding to everyones help sooner but I suddenly experienced the effect of how difficult it is for ISPs to stay in business. Anyway, I finally found out that the problem was in the ADO objects. I had to download a patch from Delphi and all problems went away. I aprreciate everyones input and I hope this site continues for a long time to come.

Sincerely,

jcfrasco

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top