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!

Recordcount returning -1

Status
Not open for further replies.

robinsql

Programmer
Aug 2, 2002
236
IE
Hi,

Can somebody please explain why this returns -1 as the recordcount when there are in fact, two records?

rs.Open sSQL, m_Conn, adOpenKeyset, adLockOptimistic
lNoOfCartons = rs.RecordCount

Thanks,

Robin
 
The recordset is returning -1 because of the type of recordset you are opening. Try changing the recordset to static and see if you get the correct recordcount.
 
A key set cursor will initially only return a key or keys to the row(s) of data. The data is fetched and the recordscount incremented, using the key, when you actually move through the recordset. As a result the inital recordcount does not exist and returns a -1.

Take Care,

zemp

"Show me someone with both feet on the ground and I will show you someone who can't put their pants on."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top