% If Session("project1_status") <> "login" Then Response.Redirect "login.asp" %> <% Response.expires = 0 Response.expiresabsolute = Now() - 1 Response.addHeader "pragma", "no-cache" Response.addHeader "cache-control", "private" Response.CacheControl = "no-cache" %> <% Response.Buffer = True ' Single delete record key = Request.querystring("key") If key = "" Or IsNull(key) Then key = Request.Form("key") End If If key = "" Or IsNull(key) Then Response.Redirect "contactslist.asp" sqlKey = sqlKey & "[contactID]=" & "" & key & "" ' Get action a = Request.Form("a") If a = "" Or IsNull(a) Then a = "I" ' Display with input box End If ' Open Connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case a Case "I": ' Display strsql = "SELECT * FROM [contacts] WHERE " & sqlKey Set rs = Server.CreateObject("ADODB.Recordset") rs.Open strsql, conn If rs.Eof Then Response.Clear Response.Redirect "contactslist.asp" Else rs.MoveFirst End If Case "D": ' Delete strsql = "SELECT * FROM [contacts] WHERE " & sqlKey Set rs = Server.CreateObject("ADODB.Recordset") rs.Open strsql, conn, 1, 2 Do While Not rs.Eof rs.Delete rs.MoveNext Loop rs.Close Set rs = Nothing conn.Close Set conn = Nothing Response.Clear Response.Redirect "contactslist.asp" End Select %>
Delete from TABLE: contacts
Back to List