<%@ Language=VBScript %> <% Response.Buffer = True %> <% // PgP put this together from a variety of sources // Distributed 7/15/2003 at the Teaching with the Internet Seminar, WSU // This script is designed to submit up to 12 questions to an Access database // // PgP 1/26/2003 Added function to prevent errors with apostrophe in text field data strings // See Kauffman's Beginning ASP Databases, page 234 Function NoQuoteError(strField) NoQuoteError = Replace(Replace(strField, "'", "''"), CHR(34), """) End Function %> <% // Patrick G. Paulson 1/8/2003 Written to collect student HW into a database, and record time of submittal // If you "Compact and Repair" the database on the webserver it removes modify permissions so web users cannot add records to the database // // if you want to check for null values in Question fields, if any nulls, show error message // if you do not care if there are null values, make sure the fields you send data to in the .mdb file // have the "Allow Zero Length = Yes" in the table field properties // // If cstr(request.form("Question01") )= "" OR cstr(request.form("Question02") )= "" OR cstr(request.form("Question03") )= "" // Response.Write("Please make a selection for each question, and write a few words for each comment") // Response.Write("

Back to Course Evaluation!

") // Response.end // end if // PgP 2/18/03 added PIN number capability Dim objConn set objConn = Server.CreateObject("ADODB.Connection") strInsert = "INSERT into tblHW (FirstName, LastName, PIN, Semester, Class, Section, Assignment, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12) " strValues = " VALUES ('" & cstr(NoQuoteError(request.form("FirstName"))) & "'," & "'" & _ cstr(NoQuoteError(request.form("LastName"))) & "'," & "'" & cstr(NoQuoteError(request.form("PIN"))) & "'," & "'" & _ request.form("Semester") & "'," & "'" & request.form("Class") & "'," & "'" & _ request.form("Section") & "'," & "'" & request.form("Assignment") & "'," & "'" & _ cstr(NoQuoteError(request.form("q1"))) & "'," & "'" & cstr(NoQuoteError(request.form("q2"))) & "'," & "'" & _ cstr(NoQuoteError(request.form("q3"))) & "'," & "'" & cstr(NoQuoteError(request.form("q4"))) & "'," & "'" & _ cstr(NoQuoteError(request.form("q5"))) & "'," & "'" & cstr(NoQuoteError(request.form("q6"))) & "'," & "'" & _ cstr(NoQuoteError(request.form("q7"))) & "'," & "'" & cstr(NoQuoteError(request.form("q8"))) & "'," & "'" & _ cstr(NoQuoteError(request.form("q9"))) & "'," & "'" & cstr(NoQuoteError(request.form("q10"))) & "'," & "'" & _ cstr(NoQuoteError(request.form("q11"))) & "'," & "'" & cstr(NoQuoteError(request.form("q12"))) & "') ;" strSQL = strInsert & strValues // write records to the Spring 2003 HW database table // *** MUST CHANGE THE TABLE NAME EACH SEMESTER *** // For troubleshooting and debugging SQL statements Response.write(strSQL) // *** WARNING *** // Must change path to match your settings objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("/username/studenthw") & "\" & "Weburls.mdb" // Execute the SQL Statement objConn.Execute(strSQL) Response.write("

") Response.write("Data added, db connection closed") objConn.close set objConn = Nothing // Response.Write("

" & "Your homework was submitted at " & time() & " on " & date()) Response.Write("

" & request.form("FirstName") & " " & request.form("LastName") & "'s homework assignment " & request.form("Assignment") & " was submitted at " & time() & " on " & date()) // Remember to put this statement just before head end tag when done if you want to redirect // %> Professor Yyyy HW Submission

This .asp script was last modified on 5/22/2003

Winona State University
Fall 2003

Professor Yyyy's class

Thank you, your homework was submitted successfully.

Yyyy's Home Page