Solved

RECORSET ROWCOUNT FROM SQL TO ASP VARIABLE?

Posted on 2004-09-29
8
1,625 Views
Last Modified: 2008-01-09
Hi Experts,

Simple one for you.

I have the following recorset to return a record count from a dbase table using SQL:



Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = MM_ET_STRING
RS.Source = "select count(*) from et_infoPages where pageType='" & trim(pageType) & "' and parameter1='" & trim(country) & "'"
'response.write("<br><br>" & RS.Source & "<br><br>")
RS.CursorType = 0
RS.CursorLocation = 2
RS.LockType = 3
RS.Open()
RS_numRows = 0


*************************code needed here*************************


RS.Close()
set RS = nothing


I need to stuff the resultant recordcount value into a variable. How do I do this?




Thanks,



PJORDANNA

0
Comment
Question by:pjordanna
  • 5
  • 2
8 Comments
 
LVL 6

Expert Comment

by:pkaleda
ID: 12178546

If not RS.eof then
on error resume next
'Write header code here like response.write("Header")

While not RS.EOF

'Write your body here such as response.write(rs.fields("field1"))


rs.movenext()
wend

'write footer information here
end if

0
 
LVL 31

Accepted Solution

by:
alorentz earned 500 total points
ID: 12178582
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = MM_ET_STRING
RS.Source = "select count(*) from et_infoPages where pageType='" & trim(pageType) & "' and parameter1='" & trim(country) & "'"
'response.write("<br><br>" & RS.Source & "<br><br>")
RS.CursorType = 2
RS.CursorLocation = 2
RS.LockType = 3
RS.Open()
RS.MoveLast
ct = rs.recordcount  '<---------------RECORD COUNT
RS_numRows = 0
0
 
LVL 31

Expert Comment

by:alorentz
ID: 12178597
0
 
LVL 31

Expert Comment

by:alorentz
ID: 12178605
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:pjordanna
ID: 12178819
alorentz,

The rs.recordcount line is returning a value of -1

The value should be 21 for the parameters I have chosen (as it is when I check in SQL)


any ideas?



PJORDANNA
0
 

Author Comment

by:pjordanna
ID: 12178857
alorentz,

OK I sorted it. Thanks!



PJORDANNA
0
 
LVL 31

Expert Comment

by:alorentz
ID: 12178859
>>The rs.recordcount line is returning a value of -1

That is described in the links I provided....
0
 
LVL 31

Expert Comment

by:alorentz
ID: 12178860
Glad to help...good luck!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now