Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2004, 08:02 PM
Registered User
 
Join Date: Jul 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to store checkbox value in database mona_1dec Struts 22 July 8th, 2011 04:29 PM
update database with checkbox mike7510uk ASP.NET 2.0 Basics 1 December 12th, 2006 07:10 AM
Pulling records from the database debjanib ASP.NET 1.0 and 1.1 Professional 2 April 17th, 2006 09:03 AM
checkbox from database ? please help me. majidnakit JSP Basics 0 September 14th, 2005 03:53 PM
Dynamically pulling table names from a database conundrum Access ASP 2 December 21st, 2003 07:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.