<% 'Dimension variables Dim adoCon 'Holds the Database Connection Object Dim rsAddComments 'Holds the recordset for the new record to be added Dim strSQL 'Holds the SQL query to query the database 'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection") 'Set an active connection to the Connection object using a DSN-less connection adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &Server.MapPath("mstff2006.mdb") 'Create an ADO recordset object Set rsAddComments = Server.CreateObject("ADODB.Recordset") 'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT Table1.Teacher, Table1.School, Table1.Grade, Table1.Students, Table1.Adults FROM Table1;" 'Set the cursor type we are using so we can navigate through the recordset rsAddComments.CursorType = 2 'Set the lock type so that the record is locked by ADO when it is updated rsAddComments.LockType = 3 'Open the recordset with the SQL query rsAddComments.Open strSQL, adoCon 'Tell the recordset we are adding a new record to it rsAddComments.AddNew 'Add a new record to the recordset rsAddComments.Fields("Teacher") = Request.Form("Teacher") rsAddComments.Fields("School") = Request.Form("School") rsAddComments.Fields("Grade") = Request.Form("Grade") rsAddComments.Fields("Students") = Request.Form("Students") rsAddComments.Fields("Adults") = Request.Form("Adults") 'Write the updated recordset to the database rsAddComments.Update 'Reset server objects rsAddComments.Close Set rsAddComments = Nothing Set adoCon = Nothing 'Redirect to the guestbook.asp page Response.Redirect "guestbook.asp" %>
Teacher:
School: Grade: Students: Adults: