Solved

RECORSET ROWCOUNT FROM SQL TO ASP VARIABLE?

Posted on 2004-09-29
8
1,624 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

18 Experts available now in Live!

Get 1:1 Help Now