home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 July / APC47-1.ISO / workshop / win95 / pws / iis4_06.cab / viewdb.asp < prev    next >
Encoding:
Text File  |  1997-10-12  |  1.9 KB  |  79 lines

  1. <!-- noprod -->
  2. <% @language=vbscript %>
  3. <html>
  4. <head>
  5.     <title> Replace this text with a title. </title>
  6. </head>
  7. <body bgcolor="#FFFFFF" text="#000000">
  8.  
  9. <%
  10. if request.form("sort")<> "" THEN
  11.     StrSort=request.form("sort") 
  12. ELSE
  13.     StrSort="TB1 ASC"
  14. END IF
  15.  
  16. strQuery="SELECT * FROM SampleDb ORDER BY " &StrSort
  17.  
  18.  
  19. 'Database path statement for restricted viewing of the database.
  20. strProvider="DRIVER=Microsoft Access Driver (*.mdb); DBQ=" & Server.MapPath("\iisadmin") & "\website\sampledb.mdb;"
  21.  
  22. 'Database path statement to allow visitors to view the database.
  23. 'strProvider="DRIVER=Microsoft Access Driver (*.mdb); DBQ=" & Server.MapPath("iisadmin") & "\website\sampledb.mdb;"
  24.  
  25.  
  26. IF Request("ID") <> "" THEN
  27.     strIDNum=Request("ID")
  28.     set objConn = server.createobject("ADODB.Connection")
  29.     objConn.Open strProvider
  30.     set cm = Server.CreateObject("ADODB.Command")
  31.     cm.ActiveConnection = objConn
  32.     cm.CommandText = "DELETE FROM SampleDb WHERE ID = " &strIDNum
  33.     cm.Execute
  34. END IF
  35.  
  36. Set rst = Server.CreateObject("ADODB.recordset")
  37. rst.Open strQuery, strProvider
  38. %>
  39.  
  40.  
  41. <h1> Replace this text with a page heading. </h1>
  42.  
  43. <form name=viewdb.asp action=viewdb.asp method=post>
  44. <table border=1 cellspacing=3 cellpadding=3 rules=box>
  45. <%
  46. ON ERROR RESUME NEXT
  47. IF rst.EOF THEN
  48.     Response.Write "There are no entries in the database."
  49. ELSE%>
  50.     <tr>
  51.     <% 
  52.     
  53.     'Response.Write "<td width=200><center>Delete Record</center></td>"
  54.     
  55.     FOR i = 1 to rst.Fields.Count -1 
  56.     Response.Write "<td width=200><input name=sort value=" & rst(i).Name & " type=submit></td>"
  57.     NEXT    
  58.     
  59.     WHILE NOT rst.EOF %>
  60.         <tr>
  61.         <% 
  62.  
  63.         'Response.Write "<td align=left valign=top bgcolor='#ffffff'><a href=viewdb.asp?id=" & rst(0) & ">Delete</a></td>"        
  64.  
  65.         FOR i = 1 to rst.fields.count - 1
  66.         Response.Write "<td align=left valign=top bgcolor='#ffffff'>" & rst(i) &"</td>"
  67.         NEXT 
  68.         rst.MoveNext
  69.     WEND
  70. END IF
  71. %>
  72. </table>
  73. </form>
  74.  
  75.  
  76.  
  77. </body>
  78. </html>
  79.