mattboyslim
Programmer
How do I display the number of records in a recordset? The reason I ask is because I need to determine if a recordset contains only 1 record, and if it does, then display a different heading, say "Records" versus "Record".
Here is my SQL query:
==================================
<%
Dim rs_attractionscat
Dim rs_attractionscat_numRows
Set rs_attractionscat = Server.CreateObject("ADODB.Recordset")
rs_attractionscat.ActiveConnection = MM_conn_portalokoboji_STRING
rs_attractionscat.Source = "SELECT * FROM tb_attractions WHERE f_categoryID = " + Replace(Request.QueryString("cat"), "'", "''") + ""
rs_attractionscat.CursorType = 0
rs_attractionscat.CursorLocation = 2
rs_attractionscat.LockType = 1
rs_attractionscat.Open()
rs_attractionscat_numRows = 0
%>
====================================
If I just use rs_attractions.Recordcount, then I get a result of -1, but apparently that is because I'm using MSAccess.
I found some other code, which is shown here:
====================================
<%
'Long recordset counting using a simple loop by Barry Wright
Dim strCount
strCount = 0
While NOT rs_attractionscat.EOF AND NOT rs_attractionscat.BOF
strCount = strCount + 1
rs_attractionscat.MoveNext()
Wend
%>
<%
'Write the amount of records in the Recordset
Response.Write(strCount)
%>
====================================
The problem I have, is that now my recordset for rs_attractionscat no longer works when I add the above code in. Any ideas why?
Thanks in advance,
Matt
Here is my SQL query:
==================================
<%
Dim rs_attractionscat
Dim rs_attractionscat_numRows
Set rs_attractionscat = Server.CreateObject("ADODB.Recordset")
rs_attractionscat.ActiveConnection = MM_conn_portalokoboji_STRING
rs_attractionscat.Source = "SELECT * FROM tb_attractions WHERE f_categoryID = " + Replace(Request.QueryString("cat"), "'", "''") + ""
rs_attractionscat.CursorType = 0
rs_attractionscat.CursorLocation = 2
rs_attractionscat.LockType = 1
rs_attractionscat.Open()
rs_attractionscat_numRows = 0
%>
====================================
If I just use rs_attractions.Recordcount, then I get a result of -1, but apparently that is because I'm using MSAccess.
I found some other code, which is shown here:
====================================
<%
'Long recordset counting using a simple loop by Barry Wright
Dim strCount
strCount = 0
While NOT rs_attractionscat.EOF AND NOT rs_attractionscat.BOF
strCount = strCount + 1
rs_attractionscat.MoveNext()
Wend
%>
<%
'Write the amount of records in the Recordset
Response.Write(strCount)
%>
====================================
The problem I have, is that now my recordset for rs_attractionscat no longer works when I add the above code in. Any ideas why?
Thanks in advance,
Matt