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

Whenever I use ADORecordset RecordCount property I always get -1

Status
Not open for further replies.

MyIronLung

Programmer
Jul 17, 2001
11
0
0
US

HELP! I am using a simple query on a standard Microsoft Access sample DB(see code below). It wries out 13 records, but says the recordcount is -1. Why? HELP!

Thanks in advance.
-Chris

<HTML>
<HEAD>
<TITLE>Contact information</TITLE>
</HEAD>
<BODY>

<%
Dim objConn
Dim objRec

Set objConn = Server.CreateObject (&quot;ADODB.Connection&quot;)
Set objRec = Server.CreateObject (&quot;ADODB.Recordset&quot;)

objConn.Open &quot;DSN=Contact&quot;

objRec.Open &quot;Contact&quot;, objConn, 0, 1 , 2

objRec.MoveFirst

While Not objRec.EOF
Response.Write objRec(&quot;Name&quot;) & &quot;<BR>&quot;
objRec.MoveNext
Wend

Response.Write (objRec.RecordCount)

objRec.Close
objConn.Close
Set objRec = Nothing
Set objConn = Nothing

%>

</BODY>
</HTML>
 
your cursor needs to be set to one that supports backward movement (such as adOpenStatic). see faq333-618 for full information on the the cursors available.

good luck
leo
 
I changed the code to:

objRec.Open &quot;Contact&quot;, objConn, adOpenStatic

and it still returns RecordCount = -1

-Chris
 
did you include adovbs.inc at the top of your file?

ex:
<!--#include file=&quot;adovbs.inc&quot;-->

you need to make sure that you have a copy of the .inc file, though (i think it sits in your windows/winnt directory... i'm not sure...)
 
You da man! :)

More to the point I'm not da man. :)

Thanks alot. It works wonderfully now.

-Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top