Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: recordcount returns -1 (JScript)


Message #1 by "hans bacher" <hans.h.bacher@a...> on Sun, 1 Dec 2002 16:07:56
recordcount always returns -1 when using JScript and MySQL

here is the code ....

		<%
			
			SID = Request.QueryString("SID");
			theSerialNumber = Request.QueryString
("theSerialString");
			
			
			var oConn;		
			var oRs;		
					

		   
			theDatabase = "Driver={MySQL ODBC 3.51 Driver}; 
Server=localhost; Option=16834; Database=ocg; Username=thex;";
			
			oConn = Server.CreateObject("ADODB.Connection");
			theRS = Server.CreateObject("ADODB.Recordset");
			oConn.Open(theDatabase);
			sql = "SELECT * From certificate WHERE 
SerialNumber = '" + theSerialNumber + "' AND Session = '" + SID + "'";
			
			theRS.Open(sql, oConn, adOpenStatic);
			
						
			theCount = theRS.RecordCount;
			
			Response.Write(theCount);

	
			theRS.close();
			oConn.close();
		%>
Message #2 by Greg Griffiths <greg2@s...> on Sun, 01 Dec 2002 20:05:43 +0000
Not al drivers / recordset types support this function - see pgs 236/237 of 
ASP in a Nutshell for more.

At 16:07 01/12/02 +0000, you wrote:
>recordcount always returns -1 when using JScript and MySQL
>
>here is the code ....
>
>                 <%
>
>                         SID = Request.QueryString("SID");
>                         theSerialNumber = Request.QueryString
>("theSerialString");
>
>
>                         var oConn;
>                         var oRs;
>
>
>
>                         theDatabase = "Driver={MySQL ODBC 3.51 Driver};
>Server=localhost; Option=16834; Database=ocg; Username=thex;";
>
>                         oConn = Server.CreateObject("ADODB.Connection");
>                         theRS = Server.CreateObject("ADODB.Recordset");
>                         oConn.Open(theDatabase);
>                         sql = "SELECT * From certificate WHERE
>SerialNumber = '" + theSerialNumber + "' AND Session = '" + SID + "'";
>
>                         theRS.Open(sql, oConn, adOpenStatic);
>
>
>                         theCount = theRS.RecordCount;
>
>                         Response.Write(theCount);
>
>
>                         theRS.close();
>                         oConn.close();
>                 %>



Message #3 by "Kim Iwan Hansen" <kimiwan@k...> on Sun, 1 Dec 2002 22:49:25 +0100
...or if you're not the lucky owner of exactly that book, do like the rest
of us and look it up on the internet:
http://www.adopenstatic.com/faq/recordcounterror.asp

-Kim

-----Original Message-----
From: Greg Griffiths [mailto:greg2@s...]
Sent: 1. december 2002 21:06
To: ASP Databases
Subject: [asp_databases] Re: recordcount returns -1 (JScript)


Not al drivers / recordset types support this function - see pgs 236/237 of
ASP in a Nutshell for more.

At 16:07 01/12/02 +0000, you wrote:
>recordcount always returns -1 when using JScript and MySQL
>
>here is the code ....
>
>                 <%
>
>                         SID = Request.QueryString("SID");
>                         theSerialNumber = Request.QueryString
>("theSerialString");
>
>
>                         var oConn;
>                         var oRs;
>
>
>
>                         theDatabase = "Driver={MySQL ODBC 3.51 Driver};
>Server=localhost; Option=16834; Database=ocg; Username=thex;";
>
>                         oConn = Server.CreateObject("ADODB.Connection");
>                         theRS = Server.CreateObject("ADODB.Recordset");
>                         oConn.Open(theDatabase);
>                         sql = "SELECT * From certificate WHERE
>SerialNumber = '" + theSerialNumber + "' AND Session = '" + SID + "'";
>
>                         theRS.Open(sql, oConn, adOpenStatic);
>
>
>                         theCount = theRS.RecordCount;
>
>                         Response.Write(theCount);
>
>
>                         theRS.close();
>                         oConn.close();
>                 %>


Message #4 by "Ken Schaefer" <ken@a...> on Tue, 3 Dec 2002 14:03:26 +1100
...and rather than using .RecordCount() use .GetRows()/UBound() and an
adOpenForwardOnly cursor instead.

www.adopenstatic.com/faq/recordcountalternatives.asp

I was going some WAST testing on the weekend, and adOpenForwardOnly gives
you 65% more requests serviced than adOpenStatic on SQL Server, and a
similar increase with Jet.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Kim Iwan Hansen" <kimiwan@k...>
Subject: [asp_databases] Re: recordcount returns -1 (JScript)


: ...or if you're not the lucky owner of exactly that book, do like the rest
: of us and look it up on the internet:
: http://www.adopenstatic.com/faq/recordcounterror.asp
:
: -Kim
:
: -----Original Message-----
: From: Greg Griffiths [mailto:greg2@s...]
: Sent: 1. december 2002 21:06
: To: ASP Databases
: Subject: [asp_databases] Re: recordcount returns -1 (JScript)
:
:
: Not al drivers / recordset types support this function - see pgs 236/237
of
: ASP in a Nutshell for more.
:
: At 16:07 01/12/02 +0000, you wrote:
: >recordcount always returns -1 when using JScript and MySQL
: >
: >here is the code ....
: >
: >                 <%
: >
: >                         SID = Request.QueryString("SID");
: >                         theSerialNumber = Request.QueryString
: >("theSerialString");
: >
: >
: >                         var oConn;
: >                         var oRs;
: >
: >
: >
: >                         theDatabase = "Driver={MySQL ODBC 3.51 Driver};
: >Server=localhost; Option=16834; Database=ocg; Username=thex;";
: >
: >                         oConn = Server.CreateObject("ADODB.Connection");
: >                         theRS = Server.CreateObject("ADODB.Recordset");
: >                         oConn.Open(theDatabase);
: >                         sql = "SELECT * From certificate WHERE
: >SerialNumber = '" + theSerialNumber + "' AND Session = '" + SID + "'";
: >
: >                         theRS.Open(sql, oConn, adOpenStatic);
: >
: >
: >                         theCount = theRS.RecordCount;
: >
: >                         Response.Write(theCount);
: >
: >
: >                         theRS.close();
: >                         oConn.close();
: >                 %>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index