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 htmlList
   If bgDebug Then
      ogDebug.WriteLine("Dumping page variables in htmlList():")
      myDump
   End If

   If sgSubmit = "Search" Then
   ElseIf sgSubmit = "Update" Then
   ElseIf sgSubmit = "Insert" Then
   ElseIf sgSubmit = "Select" Then
   ElseIf sgSubmit = "Delete" Then
   Else 
   End If

'  Performing the search
   sCriteria = ""
   If hgDbParam("ID") <> "" Then
      sCriteria = sCriteria _ 
         & " AND ID = " & hgDbParam("ID")
   End If
   If hgDbParam("TopicID") <> "" Then
      sCriteria = sCriteria _ 
         & " AND TopicID = " & hgDbParam("TopicID")
   End If
   If hgDbParam("Name") <> "" Then
      sCriteria = sCriteria _ 
         & " AND Name LIKE '%" & hgDbParam("Name") & "%'"
   End If
   If hgDbParam("Email") <> "" Then
      sCriteria = sCriteria _ 
         & " AND Email LIKE '%" & hgDbParam("Email") & "%'"
   End If
   If hgDbParam("IpAddress") <> "" Then
      sCriteria = sCriteria _ 
         & " AND IpAddress LIKE '%" & hgDbParam("IpAddress") & "%'"
   End If
   If hgDbParam("Timestamp") <> "" Then
      sCriteria = sCriteria _ 
         & " AND Timestamp = #" & hgDbParam("Timestamp") & "#"
   End If
   sCriteria = Replace(sCriteria, " AND", "", 1, 1)
   Set rsComment = Server.CreateObject("ADODB.Recordset")
   sSQL = "SELECT * FROM hyComment"
   If sCriteria <> "" Then
      sSQL = sSQL & " WHERE " & sCriteria
   End If
   sSQL = sSQL & " ORDER BY ID DESC"
   If bgDebug Then
      ogDebug.WriteLine("The search query::")
      ogDebug.WriteLine("sSQL = (" & sSQL & ")")
   End If

   rsComment.Open sSQL, ogConn
   If bgDebug Then
      ogDebug.WriteLine("Count = (" & rsComment.RecordCount & ")")
   End If
   
   If rsComment.EOF Then
      htmlNotice("No record found.")
   Else 
      Response.Write("<table class=hy_list cellspacing=1" _
         & " cellpadding=3>")
      Response.Write("<tr class=hy_list_button><td colspan=7>" _ 
         & "<input type=submit name=Submit value=Select>" _ 
         & "<input type=submit name=Submit value=Delete></td></tr>")
      sClass="hy_list_item_lo"
      Do While NOT rsComment.EOF
'         If CStr(rsComment("ID")) = hgPgParam("ID") Then
         If CStr(rsComment("ID")) = hgPgParam.Item("ID") Then
            sCheck = " checked"
         Else
            sCheck = ""
         End If

         Response.Write("<tr class="& sClass & ">" _ 
            & "<td><input type=radio name=ItemID value=" _ 
            & rsComment("ID") & sCheck & ">" _
            & "</td><td>" & rsComment("ID") _
            & "</td><td>" & rsComment("TopicID") _
            & "</td><td>" & rsComment("Name") _
            & "</td><td>" & rsComment("Email") _
            & "</td><td>" & rsComment("Timestamp") _
            & "</td><td>" & rsComment("IpAddress") _
            & "</td></tr>")
         rsComment.MoveNext
         If sClass = "hy_list_item_lo" Then
            sClass = "hy_list_item_hi"
         Else
            sClass = "hy_list_item_lo"
         End If
      Loop
      Response.Write("<tr class=hy_list_button><td colspan=7>" _ 
         & "<input type=submit name=Submit value=Select>" _ 
         & "<input type=submit name=Submit value=Delete></td></tr>")
      Response.Write("</table>")
   End If
   set rsComment = Nothing
End Function

Function removeHTML(strText)
   Dim RegEx
   Set RegEx = New RegExp
   RegEx.Pattern = "<[^>]*>"
   RegEx.Global = True
   RemoveHTML = RegEx.Replace(strText, "")
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