Pulling individual checkbox requests into database
I have a page that pulls up data from a table (tblStudents) and displays that information along with some Session variables into ASPPage1.asp. Next to their name is a checkbox. If the checkbox is checked, then add that name to a table (tblClassHistory). There could be multiple checkboxes checked, one checked or none checked.
Data from Session More Session Data Again Session Data
FName LName StuID Checked
Abraham Lincoln 03301 [ ]
Barley Wheat 00001 [ ]
Randell Bob 000222 [ ]
Tattoo Jewel 00223 [ ]
I then want to process those students checked so that the table tblClassHistory will be updated with each of the students checked to include information from the Session variables as well as from the tblStudents information. This is done in ASPProcess1.asp which opens the table tblClassHistory to put the data into as well as opens tblStudents to pull data from to put into tblClassHistory.
That is the ASPProcess1.asp page:
<%
Dim â¦.
'connect and open table ClassHistory
set objConn = Server.CreateObject("ADODB.Connection")
set objRec = Server.CreateObject("ADODB.Recordset")
objConn.Open strConnDataData
strSQL = "SELECT * FROM tblClassHistory"
objRec.Open strSQL, strConnDataData
'Script for tblStudents
Dim â¦.
'connect and open table Students
set objAConn = Server.CreateObject("ADODB.Connection")
set objARec = Server.CreateObject("ADODB.Recordset")
objAConn.Open strConnDataData
strSQL1 = "SELECT * FROM tblStudents WHERE StudentID IN (" & Request("Include") & ")"
objARec.Open strSQL1, strConnDataData
For Each Request("Include")
objRec.AddNew
objRec("ClassDate") = Session("ClassDate")
objRec("ClassTime") = Session("ClassTime")
objRec("ClassLocation") = Session("ClassLocation")
objRec("ClassAsstInstruc") = Session("ClassAsstInstruc")
objRec("ClassID") = Session("ClassID")
objRec("ClassTDesc") = Session("ClassTypeID")
objRec("ClassStudFName") = objARec.fields("StudentFName")
objRec("ClassStudLName") = objARec.fields("StudentLName")
objRec("ClassStudID_ID") = objARec.fields("StudentID_ID")
objRec("ClassStudID") = objARec.fields("StudentID")
objRec("CompID_ID") = Session("CompNumber")
objRec("InstrucID_ID") = Session("UserID")
objRec("InstrucName") = Session("UserName")
objARec.MoveNext
objRec.Update
objRec.Close
Set objRec = Nothing
Response.Redirect("AEDInstRosterAdd2.asp")
'End If
%>
Again, I am opening the tblClassHistory to add each new student and getting some of their information from tblStudents.
What I am trying to do is for every checkbox, add that student information from the table tblStudents and add a new record into the table tblClassHistory with Session variables and information from the tblStudents, and make sure that a new record is added for every student whose checkbox was checked.
So, âFor Each Request("Include") â is obviously wrong but, what should it be in order to add the individual students with information from tblStudents and Session variables into tblClassHistory?
I apologize if the code seems ugly and whatnot but, I am just trying to add new items to a database and not win any beauty prizes.
I do appreciate any help. Thank you.
|