|
-
Apr 22nd, 2002, 11:47 AM
#1
Thread Starter
Frenzied Member
ASP VBScript ADO Recordset RecordCount
Given this code...
Code:
<% @Language="VBScript" %>
<%
Option Explicit
%>
<!---#include virtual="/Gabby/Utilities.inc"-->
<!---#include virtual="/Gabby/Globals.inc"-->
<%
Dim adodbConn, adodbRS
Dim strSQL
Set adodbConn = Server.CreateObject("ADODB.Connection")
Set adodbRS = Server.CreateObject("ADODB.Recordset")
adodbConn.Open MonitorCS, MonitorUserID, MonitorPassword
strSQL = "SELECT Node FROM Node"
adodbRS.Open strSQL, adodbConn, adOpenForwardOnly, adLockReadOnly
%>
<html>
<head>
<title>Test Page</title>
</head>
<body>
<p><%=adodbRS.RecordCount%></p>
<%While Not adodbRS.EOF%>
<p><%=adodbRS.Fields("Node").Value%></p>
<%adodbRS.MoveNext%>
<%Wend%>
</body>
</html>
I get this result...
Code:
-1
CICS-Region-1
CICS-Region-2
CICS-Region-3
localhost
NT-BackOffice-Server
Unix-DB-Server
Unix-DB-Server
Unix-DB-Server
UnixGateway
UnixGateway2
Since ADODBRecordset.RecordCount obviously doesn't work, is there any other way?
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Apr 22nd, 2002, 11:52 AM
#2
try this sql statement:
SELECT COUNT(Node) as NodeCount, Node FROM Node ORDER BY Node
You will now have a column NodeCount that contains the node count.
Hope this helps,
Joan
-
Apr 22nd, 2002, 12:05 PM
#3
Thread Starter
Frenzied Member
I always forget aliasing in SQL statements. I actually like that solution, though. A slap in the face to VBScript.
Though, I'm having problems.
Code:
strSQL = "SELECT Node, COUNT(Node) as NodeCount FROM Node"
'or
strSQL = "SELECT COUNT(Node) as NodeCount, Node FROM Node"
Both give me an error.
[Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'Node' as part of an aggregate function.
If I drop "Node" and just ask for "COUNT(Node) as NodeCount" it works, though I just get the count and not the data.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Apr 22nd, 2002, 12:26 PM
#4
Hyperactive Member
yourRS.recordcount should work if you substitute
'adOpenKeyset' for 'adOpenForwardOnly'
-
Apr 22nd, 2002, 01:18 PM
#5
Sorry, instead of the ORDER BY. Use GROUP BY...
SELECT COUNT(Node) as NodeCount, Node FROM Node GROUP BY Node
-
Apr 22nd, 2002, 02:37 PM
#6
Thread Starter
Frenzied Member
There we go, thank you both.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|