• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1647
  • Last Modified:

RECORSET ROWCOUNT FROM SQL TO ASP VARIABLE?

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
pjordanna
Asked:
pjordanna
  • 5
  • 2
1 Solution
 
pkaledaCommented:

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
 
alorentzCommented:
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
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!

 
alorentzCommented:
0
 
pjordannaAuthor Commented:
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
 
pjordannaAuthor Commented:
alorentz,

OK I sorted it. Thanks!



PJORDANNA
0
 
alorentzCommented:
>>The rs.recordcount line is returning a value of -1

That is described in the links I provided....
0
 
alorentzCommented:
Glad to help...good luck!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now