|
 |
asp_databases thread: RE: RecordCount = -1
Message #1 by "Walter Torres" <walter@t...> on Mon, 10 Feb 2003 02:02:55
|
|
> you should use adoROCOL.cursorlocation=3 before opening the recordset.
-----Original Message-----
From: Bhupendra_Sharma@r... [mailto:Bhupendra_Sharma@r...]
Sent: Saturday, December 07, 2002 10:31 AM
To: ASP Databases
Subject: [asp_databases] RecordCount = -1
Importance: High
I'm having this code in one of my ASP's
set adoROCOL = createobject("adodb.recordset")
adoROCOL.open sqlstr, conn, adOpenStatic, adLockOptimistic
response.write adoROCOL.recordcount
still why is it that i'm getting the result as -1
can somebody please help me
regards
Message #2 by "Walter Torres" <walter@t...> on Mon, 10 Feb 2003 02:13:08
|
|
OK, I have this (in JavaScript)...
// Define SQL statement
var sSql = "SELECT * FROM mytable";
// Make database Object and open connection
var objDataConn = Server.CreateObject ( " ADODB.Connection" );
objDataConn.Open ( "DNS=myDB; UIS=myPWD " )'
// Execute SQL statement
var rsData = objDataConn.Execute ( sSql );
// Move to first Record in RecordSet
rsData .MoveFirst();
// Write out how many records we have to deal with
Repsonse.Write ( rsData.RecordCount );
This always gives me -1
> you should use adoROCOL.cursorlocation=3 before opening the recordset.
I didn't understand where to place this statement in this code piece. In
fact I didn't understand how to translate this into JS.
Can anyone enlighten me?
Thanks
Walter
Message #3 by "Ken Schaefer" <ken@a...> on Mon, 10 Feb 2003 13:41:10 +1100
|
|
www.adopenstatic.com/faq/recordcounterror.asp
explains why you are getting the error
Setting the CursorLocation is *not* the answer per se. Changing the cursor
type is.
www.adopenstatic.com/faq/recordcountalterantives.asp
gives you *better* ways to do the same thing. Accessing the .Recordcount
property results in a 20-30% drop in performance.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Walter Torres" <walter@t...>
Subject: [asp_databases] RE: RecordCount = -1
: OK, I have this (in JavaScript)...
:
: // Define SQL statement
: var sSql = "SELECT * FROM mytable";
:
: // Make database Object and open connection
: var objDataConn = Server.CreateObject ( " ADODB.Connection" );
: objDataConn.Open ( "DNS=myDB; UIS=myPWD " )'
:
: // Execute SQL statement
: var rsData = objDataConn.Execute ( sSql );
:
: // Move to first Record in RecordSet
: rsData .MoveFirst();
:
: // Write out how many records we have to deal with
: Repsonse.Write ( rsData.RecordCount );
:
:
: This always gives me -1
:
:
: > you should use adoROCOL.cursorlocation=3 before opening the recordset.
:
: I didn't understand where to place this statement in this code piece. In
: fact I didn't understand how to translate this into JS.
:
: Can anyone enlighten me?
|
|
 |