home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / ADO / Web / remove.asp < prev    next >
Encoding:
Text File  |  1998-07-22  |  1.8 KB  |  63 lines

  1. <%@ LANGUAGE="VBSCRIPT" %>
  2. <%  'remove.asp -- Removes products from the inventory database
  3.     '    
  4.     'This active server page will remove products from the database 
  5.     'which are submitted to it via the form from the displayp.asp page.
  6.     '
  7.     'It demonstates the capability of ADO to execute T-SQL commands
  8.     'using the command object.  In this case, it will be the DELETE command. %>
  9.     
  10. <HTML>
  11. <HEAD>
  12. <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
  13. <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
  14. <TITLE>NIMS - Product Removed from Inventory</TITLE>
  15. <LINK REL="stylesheet" TYPE="text/css" HREF="nimstyle.css">
  16. </HEAD>
  17. <BODY>
  18.  
  19. <%
  20. ' Create the first part of the T-SQL statement to be executed
  21. sqlcmd = "DELETE Products WHERE "
  22.  
  23. 'Generate WHERE clause of the SQL command by adding all selected ProductIDs to it.
  24. FOR i = 1 TO Request.Form("ProductID").Count 
  25.     sqlcmd = sqlcmd & " ProductID = " & Request.Form("ProductID")(i)
  26.     IF i <> Request.Form("ProductID").Count THEN
  27.         sqlcmd = sqlcmd & " OR"
  28.     END IF
  29. NEXT
  30.  
  31. 'Reference the Session connection variable
  32. cn = Session("cnn")
  33.  
  34. ' Create the remove command and set its properties
  35. Set cmd = Server.CreateObject("ADODB.Command") 
  36. cmd.CommandText = sqlcmd
  37. cmd.ActiveConnection = cn
  38.  
  39. ' Execute the command on the Active Connection
  40. cmd.Execute nRecordsAffected
  41.  
  42. 'Output some feedback to the user to let them know which products 
  43. 'were removed from the inventory database. %>
  44.  
  45. <CENTER>
  46. <H2>Northwind Inventory Management System</H2>
  47. <HR>
  48. </CENTER>
  49.  
  50. <H3>The following products have been removed from the inventory:</H3>
  51.  
  52. <% FOR EACH product IN Request.Form("ProductID")
  53.     Response.Write "Product #" & product & "<br>"
  54.    NEXT  %>
  55. <BR>
  56. <BR>
  57. <HR>
  58. Return to the <a href="default.htm">Main Menu</A>
  59. <BR>
  60.  
  61. </BODY>
  62. </HTML>
  63.