Solved

RECORSET ROWCOUNT FROM SQL TO ASP VARIABLE?

Posted on 2004-09-29
8
1,632 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:alorentz
ID: 12178605
0
 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

696 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