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

display the record count for a query on asp page

Status
Not open for further replies.

flybravo

Programmer
Jun 30, 2003
35
US
When I load up the webpage, the value I get is an -1, there should be at leats 4 records


<CODE>
'create an ADO connection object<BR>
Set objConn = CreateObject(&quot;ADODB.Connection&quot;)
'// Use this for SQL Server
objConn.Open &quot;Driver={SQL Server};Server=name;&quot; & _
&quot;UID=username;PASSWORD=password;DATABASE=dbName SQL;&quot;

strSQL = &quot;SELECT * FROM tblInventory&quot;
Set objRS = objConn.Execute (strSQL)
Response.Write objRS.RecordCount

</CODE>
 
The reason for this is that you are using the default &quot;firehose&quot; cursor type of adOpenForwardOnly which doesn't return a record count. Search for CursorTypeEnum in MSDN for the values. You should use a keyset or static cursor. Also search for the article &quot;Recordset Object Basics&quot; for more info.

HtH

Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top