<%@ Language=VBScript %> <% Option Explicit %> <!--#include file="adovbs.inc"--> <% 'Open a connection to the database Dim objConn Set objConn = Server.CreateObject("ADODB.Connection") objConn.ConnectionString = "DSN=Products" objConn.Open 'Get the table information for products Dim objRS Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open "Products", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable 'Display the FORM and the top of the TABLE Response.Write "<FORM METHOD=POST ACTION=""DeleteProducts.asp"">" Response.Write "<TABLE BORDER=1 CELLSPACING=1>" Dim iLoop Response.Write "<TR>" Response.Write "<TH>Delete</TH>" Response.Write "<TH>Name</TH>" Response.Write "<TH>Cost</TH>" Response.Write "</TR>" 'Display each element in the table... Do While Not objRS.EOF Response.Write "<TR>" & vbCrLf 'Create a checkbox to check for deleting, setting the checkboxes 'Value equal to the current items ProductID Response.Write "<TD><INPUT TYPE=CHECKBOX NAME=Delete " Response.Write "VALUE=" & CInt(objRS("ProductID")) & "></TD>" 'Display the name and cost of the product Response.Write vbCrLf & "<TD>" & objRS("Name") & "</TD>" Response.Write vbCrLf & "<TD>" & FormatCurrency(objRS("Cost"),2) Response.Write "</TD></TR>" & vbCrLf & vbCrLf 'Move to the next record... objRS.MoveNext Loop 'Print the end of the table, the submit button, and the 'the end of the form. Response.Write "</TABLE>" Response.Write "<P><INPUT TYPE=SUBMIT VALUE=""Delete Selected Products"">" Response.Write "</FORM>" 'Clean up our ADO objects objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing %>