Solved

RECORSET ROWCOUNT FROM SQL TO ASP VARIABLE?

Posted on 2004-09-29
8
1,629 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
 
LVL 31

Expert Comment

by:alorentz
ID: 12178597
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Button function on table is in trouble 3 39
Validating Date Part2 2 45
Display if field is NOT "" or NOT null 6 36
window close link 7 62
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 …

734 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