ASP Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.11

hyBook - A Simple Guestbook Application

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13 

ASP Tutorials - Herong's Tutorial Notes © Dr. Herong Yang

hyBook - Guestbook Application

Using MS Access Databases

ActiveX Data Object (ADO)

Controlling Response Header Lines

Microsoft Scripting Runtime DLL

Using Cookies

ASP Sessions

ASP Objects

Microsoft Script Debugger

Internet Information Services (IIS)

... Table of Contents

(Continued from previous part...)

Function doUpdate
   If hgDbParam("ID") = "" Then
      sgError = "Missing record ID."
   Else 
      sSQL = "UPDATE hyComment" _
         & " SET TopicID = " & hgDbParam("TopicID") _
         & ", Content = '" & hgDbParam("Content") & "'" _
         & ", Name = '" & hgDbParam("Name") & "'" _
         & ", Email = '" & hgDbParam("Email") & "'" _
         & ", [Timestamp] = #" & hgDbParam("Timestamp") & "#" _
         & ", IpAddress = '" & hgDbParam("IpAddress") & "'" _
         & " WHERE ID = " & hgDbParam("ID")
         If bgDebug Then
            ogDebug.WriteLine("The update query::")
            ogDebug.WriteLine("sSQL = (" & sSQL & ")")
         End If
      Set rsComment = Server.CreateObject("ADODB.Recordset")
      rsComment.Open sSQL, ogConn
      sgNotice = "Record updated."
   End If
End Function

Function doInsert
   If hgDbParam("Content") = "" Then
      sgError = "Content required."
   Else 
      hgRqParam("ID") = ""
      hgDbParam("ID") = ""
      hgPgParam("ID") = ""
      sSQL = "INSERT INTO hyComment" _
         & " (TopicID, Content, Name, Email, [Timestamp], IpAddress)" _
         & " VALUES (" & hgDbParam("TopicID") _
         & ", '" & hgDbParam("Content") & "'" _
         & ", '" & hgDbParam("Name") & "'" _
         & ", '" & hgDbParam("Email") & "'" _
         & ", #" & hgDbParam("Timestamp") & "#" _
         & ", '" & hgDbParam("IpAddress") & "'" _
         & ")"
         If bgDebug Then
            ogDebug.WriteLine("The insert query::")
            ogDebug.WriteLine("sSQL = (" & sSQL & ")")
         End If
      Set rsComment = Server.CreateObject("ADODB.Recordset")
      rsComment.Open sSQL, ogConn
      sgNotice = "Record inserted."
   End If
End Function

Function htmlDetail
   Response.Write("<table class=hy_comment cellspacing=0" _ 
      & " cellpadding=3>")
   Response.Write("<tr><td align=right>ID:</td>" _
      & "<td><input type=text size=10 maxlength=10 name=ID" _
      & " value=""" & hgPgParam("ID") & """></td></tr>")
   Response.Write("<tr><td align=right>Topic ID:</td>" _
      & "<td><input type=text size=10 maxlength=10 name=TopicID" _
      & " value=""" & hgPgParam("TopicID") & """></td></tr>")
   Response.Write("<tr><td align=right>Content:</td>" _ 
      & "<td><textarea cols=45 rows=10 wrap=virtual name=Content>" _
      & hgPgParam("Content") & "</textarea></td></tr>")
   Response.Write("<tr><td align=right>Name:</td>" _
      & "<td><input type=text size=40 maxlength=40 name=Name" _
      & " value=""" & hgPgParam("Name") & """></td></tr>")
   Response.Write("<tr><td align=right>Email:</td>" _ 
      & "<td><input type=text size=40 maxlength=40 name=Email" _
      & " value=""" & hgPgParam("Email") & """></td></tr>")
   Response.Write("<tr><td align=right>Timestamp:</td>" _
      & "<td><input type=text size=16 maxlength=16 name=Timestamp" _
      & " value=""" & hgPgParam("Timestamp") & """></td></tr>")
   Response.Write("<tr><td align=right>IP Address:</td>" _
      & "<td><input type=text size=16 maxlength=16 name=IpAddress" _
      & " value=""" & hgPgParam("IpAddress") & """></td></tr>")
   Response.Write("<tr><td align=right>&nbsp;</td>" _ 
      & "<td><input type=submit name=Submit value=Search>" _
      & "<input type=submit name=Submit value=Update>" _ 
      & "<input type=submit name=Submit value=Insert>" _
      & "<input type=submit name=Submit value=Clear></td></tr>")
   Response.Write("</table>")
End Function

(Continued on next part...)

Part:   1  2  3  4  5  6  7  8  9  10  11  12  13 

Dr. Herong Yang, updated in 2005
ASP Tutorials - Herong's Tutorial Notes - hyBook - A Simple Guestbook Application