Click to See Complete Forum and Search --> : Registrations and Event Management


AegisIC1
02-11-2007, 11:20 AM
I am trying to create codes that will allow registration signups for events or seminars with limitted seating. Here is the code that I am using but I cant seem to get it to work.


<%@ LANGUAGE="VBSCRIPT" %>
<%
Option Explicit

Dim objConn ' Our Connection Object
Dim objRS ' Our Recordset Object
Dim strSQL ' Our SQL String to access the database
Dim strConnection ' Our Connection string to access the database
Dim i ' a counter variable
Dim var1
Dim var2
Dim ifield
Dim icount


var1=1
var2=10




' -- Create objects
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")

' -- Connection String Value
strConnection = "DSN=scott"

' -- Open the Connection
objConn.Open strConnection

' -- Our SQL Statement
strSQL = "SELECT count(*) from tblname;"

'strSQL = "SELECT firstname,lastname FROM tblname;"


' -- Populate our Recordset with data
set objRS = objConn.Execute (strSQL)


if (objRS.BOF and objRS.EOF) then
response.write "No records found"
response.end
End IF


if var1>strSQL then

Response.write("No available seating")
else

Response.write("Seating is available")

End IF


%>

russell
02-11-2007, 11:30 AM
change this
if var1>strSQL then
to
If var1 > Clng(objRS.Fields(0).Value) Then

you are comparing var1 to the sql string, not the result of the query

AegisIC1
02-11-2007, 01:15 PM
Hey, it works using the sql count statement but It does not work when I use the sql Select fname,lastname from tbltable - statement.

russell
02-14-2007, 10:35 AM
well, that is a completely different query. if u are selecting count, then u are returning a numeric value. if u select names, then u are returning string values.

your best bet is to pop the entire recordset into an array using the ado GetRows method, then check the ubound(arrayName, 2)+1 to get the recordcount and then loop the array to get at the values.