Write_new.asp
Page source
Write new record
Values are required for each field.
Script listing
Write new record
<%
' If the user enters a complete record, this script adds it to
' the database and evokes roster_view
' If there is missing data, it displays an error message and
' buttons for evoking either roster_view or new_student.
' Get field values from the form variables
dim fn, mn, ln, eml, url
fn = Request.form ("FirstName")
ln = Request.form ("LastName")
eml = Request.form ("Email")
url = Request.form ("URL")
' Check for a complete form
If (fn="" or ln="" or eml="" or url ="") then 'missing data
response.write ("Values are required for each field. ")
response.write ("
")
response.write ("")
else ' values entered for each field, write the new record
' Create and establish data connection called "DataConn"
Dim DataConn
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Mode = 3 '3 = adModeReadWrite
DataConn.ConnectionTimeout = 5
DataConn.CommandTimeout = 12
DataConn.Open Session.Value("DBOpen")
' Write the record to the database
dim cmdInsert
cmdInsert = "INSERT INTO Roster_CIS (FirstName,LastName,Email,URL)"
dim cmdValues
cmdValues = "values ('" & fn & "','" & ln & "','" & eml & "','" & url & "')"
cmdInsert = cmdInsert & cmdValues
DataConn.Execute cmdInsert
' return connection memory
DataConn.Close
Set DataConn = Nothing
Response.Redirect("roster_view.asp")' transition to roster_view
end if
%>