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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADOQuery returns a negative value

Status
Not open for further replies.

ozzydaws

Programmer
Dec 28, 2010
4
GB
Hi Everyone,

In one of my units I have an ADOQuery component, which I initialize like so:

Code:
with ADOQuery1 do begin
  Close;
  ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+frm_Technician.databaselocation+'btbse_ScienceBookings.mdb;Persist Security Info=False';
  SQL.Clear;
  SQl.Text := 'SELECT * FROM tbl_Bookings WHERE [WeekBeginning] = '''+frm_Technician.cmb_WeekBeginning.text+''' AND [Day] = '''+TheWeek[day]+''' ORDER BY [Period];';
  Active := true;
  Open;
end;

The query is run 5 times in a loop, with 'day' being Monday through Friday.I have 3 entries in the database which should match the 'Monday' iteration, one for 'Tuesday'and none for the rest, however ADOQuery1.RecNo equals 1, then 1 again, then -1!

I noted the exact syntax of the sql query at run time and ran it in access, which worked perfectly.

Can anybody think what is causing this? Queries called from other units work fine.

Many thanks
 
Sorry, solved the problem - I was using ADOQuery.RecNo to tell me the Record Count, and hence it was telling me the location of the pointer in the returned data set - not the number of records returned.
 
Hey there, I see you solved the problem, but thought I'd point you to some info you may find useful here:
It's an FAQ I wrote which is a customizable connection component to interact with a database.

JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top