Nate
|
| Posted: 06/12/2003, 6:13 PM |
|
Using CCS 2.1.1.20
ASP
I am attempting to develop a registration application that has two main tables.
Student table: notes student info and the class that they register for
Classes: a control table that list the various classes names and a column that tracks the number of students registered for a class.
A second column (in Classes table) notes the maxium number of students allowed to register for a class.
I have tested the code below and it works find. It was added to the "Before Show" event of the student table. It allows a student to register (insert a row in the student table) if the first part of the "if" statement test true.
My problem is I don't know how to increment the column in the Classes table to track the number of students who have registered for a classes.
Can anyone provide me with a clue (example, etc.) as how to do this in CCS.
Thanks much.
Nate
==========================================
Dim CurrentCount, MaxCount
CurrentCount = CCDLookUp("ClassCount","Classes","ClassID="&student.ClassID.value, DBadminDB) + 1
MaxCount = CCDLookUp("ClassMaxNumber","Classes","ClassID="&student.ClassID.value, DBadminDB)
If CurrentCount <= MaxCount Then
Student.InsertAllowed = True
redirect = "success.asp"
Else
redirect = "failure.asp"
Student.InsertAllowed = False
End if
|
|
|
 |
rclayh
|
| Posted: 06/12/2003, 6:26 PM |
|
In the help file under Examples Tips and Techniques - Programming - Working with databases it shows you how to execute custom SQL statements after the After Execute Update. You may also want to search on Custom Insert. Code Charge allows you to replace their insert and update with custom SQL that can update to multiple tables from one record form.
Clay
|
|
|
 |
ziggetty
|
| Posted: 06/12/2003, 11:37 PM |
|
you will need an after execute to do the second.
i tried the custom insert. make two insert from one form (php / mysql) but it did not work. only works with stored procedures which mysql not 'yet' supports.
but it was in a beta and not the latest 2.1 version. If it now would work that would be GREAT.
|
|
|
 |
Nate
|
| Posted: 06/13/2003, 2:53 AM |
|
Thanks for the suggestion. I am making progress. I added the following custom code to the "After Execute Insert" event and only need to know how to reference the "student.ClassID.value" from the "Before Insert" event. I know the code works because I substitued a "1" for student.ClassID.value and it incremented the value in the ClassCount column.
This is the last piece of the puzzle.
Thanks again.
==================================================
Dim SQL
Dim Connection
Dim ErrorMessage
SQL = "Update Classes set ClassCount = ClassCount + 1 where ClassID = student.ClassID.value"
Set Connection = New clsDBadminDB
Connection.Open
Connection.Execute(SQL)
ErrorMessage = CCProcessError(Connection)
Connection.Close
Set Connection = Nothing
On Error Goto 0
|
|
|
 |
|