Help with my code.

K

ken

Here is my code.
The end of the code is where I need help. My goal is to
keep people from signing up for the same
class twice. However, I don't want to stop them from
taking the class again if they need extra help.
Currently the code prevents anyone from sigining up twice
even if the days are different.
How do I change the code so that it prevents them from
signing up twice on the same day...but not different days.
I want ot add a dateclass = something or use the ID as the
field since Class ID's are unique but I don't know how to
write that one. Any help would be appreciated.
I put the code...yes I got help from others at work. I am
no expert.....any suggestions are appreciated Thanks in
advance!

Dim fname
Dim lname
Dim classenroll
Dim dateclass
Dim dept
Dim phone
Dim time
Dim eventID
Dim email
Dim R
Set R = Server.CreateObject("ADODB.RecordSet")

fname = Request.Form("fname")
lname = Request.Form("lname")
classenroll = Request.Form("classenroll")
dateclass = Request.Form("dateclass")
dept = Request.Form("dept")
phone = Request.Form("phone")
email = Request.Form("email")
time = Request.Form("time")
eventID = Request.Form("eventID")

If len(phone) > 0 AND len(email) > 0 Then
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")

conn.Mode = adModeReadWrite
conn.ConnectionString = "DSN=Training"
conn.Open

Dim alreadyInClass
SQL = "Select * " _
& "From Enrolled " _
& "Where ClassName = '" & classenroll & "' " _
& "And Fname = '" & Fname & "' " _
& "And Lname = '" & Lname & "' " _
& "And Attended = 0"
 
P

Peter Aitken

ken said:
Here is my code.
The end of the code is where I need help. My goal is to
keep people from signing up for the same
class twice. However, I don't want to stop them from
taking the class again if they need extra help.
Currently the code prevents anyone from sigining up twice
even if the days are different.
How do I change the code so that it prevents them from
signing up twice on the same day...but not different days.
I want ot add a dateclass = something or use the ID as the
field since Class ID's are unique but I don't know how to
write that one. Any help would be appreciated.
I put the code...yes I got help from others at work. I am
no expert.....any suggestions are appreciated Thanks in
advance!

<code snipped>

When the user registers for a class that info will be saved in the database,
right? The user's name, class ID, and other info will make this a unique
record. The technique is to write an SQL satement that will retrieve this
record when the user tries to register. The resulting recordset will be
empty if the user has not registered for the same class before. If the
recordset is not empty you can dislpay a warning to the user.
 
M

MD Websunlimited

Hi Ken,

The process would be to use a unique identifier for the student, e.g., ssan, student number then select record for that ssan that
have the same date. If you get any records then you know that they are already registered.

sSQL = "select * from class where ssan = '" & sSSAN & "' and classDate = #" & sClassDate ";"

set rs = cn.execute(sSQL)

if not rs.eof then
' admonish the student
else
'Store a new record for the class
end if
 
C

clintonG

Would I be correct to perceive that 'ssan' may be a reference to a
student's Social Security Account Number?

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/





MD Websunlimited said:
Hi Ken,

The process would be to use a unique identifier for the student, e.g., ssan,
student number then select record for that ssan that
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top