<% @Language=VBScript %> View Guest Book <% 'This section makes it possible for visitors to sort the data in the columns in ascending order. if request.form("sort")<> "" THEN StrSort=request.form("sort") ELSE StrSort="TB1 ASC" END IF strQuery="SELECT * FROM Guestbook ORDER BY " &StrSort 'Database path statement describing the driver to use and the path to the desired database. strProvider = "Driver=Microsoft Access Driver (*.mdb); DBQ=C:\Inetpub\Wwwroot\Tutorial\guestbook.mdb;" IF Request("ID") <> "" THEN strIDNum=Request("ID") 'Creates an instance of an Active server component set objConn = server.createobject("ADODB.Connection") 'Opens the connection to the data store objConn.Open strProvider 'Instantiate Command object and use ActiveConnection property to 'attach connection to Command object set cm = Server.CreateObject("ADODB.Command") cm.ActiveConnection = objConn 'Define SQL query cm.CommandText = "DELETE FROM Guestbook WHERE ID = " &strIDNum cm.Execute END IF 'Instantiate a Recordset object and open a recordset using 'the Open method Set rst = Server.CreateObject("ADODB.recordset") rst.Open strQuery, strProvider %>

Guest Book

<% ON ERROR RESUME NEXT IF rst.EOF THEN Response.Write "There are no entries in the database." ELSE%> <% 'Deletes rows from the database, this cannot be undone Response.Write "" FOR i = 1 to rst.Fields.Count -1 Response.Write "" NEXT WHILE NOT rst.EOF %> <% Response.Write "" FOR i = 1 to rst.fields.count - 1 Response.Write "" NEXT rst.MoveNext WEND END IF %>
Delete Record
Delete" & rst(i) &"