Discussion Board - How to delete the discussion?
Step 1 – We need to list out all the discussions in a table:
<% Set conn = Server.CreateObject("Adodb.Connection") conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("Adodb.Recordset") rs.open "Discuss",conn,1,3 do while not rs.eof response.write(" " " " " rs.movenext loop rs.close set rs = nothing set conn = nothing %>
User Title Post Date " & _ ") " & rs.fields("User") & " " & _ " & rs.fields("Title") & " " & _ " & rs.fields("PostDate") & " " & _
Step 2 – we need to let user to select which record that they need to delete:
<% Set conn = Server.CreateObject("Adodb.Connection") conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("Adodb.Recordset") rs.open "Discuss",conn,1,3 do while not rs.eof response.write(" " " " " rs.movenext loop rs.close set rs = nothing set conn = nothing %>
User Title Post Date " & _ ") " & rs.fields("User") & " " & _ " & rs.fields("Title") & " " & _ " & rs.fields("PostDate") & " " & _
Step 3 – We need to use the ASP script to delete the record in database:
<%
if request.form("SubmitButton")="Delete" then ‘When the user click the Submit button
if request.form("C1").count then ‘Is the user has select any record
for i=1 to request.form("C1").count ‘If Yes, use the looping to get each ID
OrderID = request.form("C1")(i)
strSQL="DELETE FROM Discuss WHERE ID="&OrderID ‘Generate the SQL
conn.execute strSQL ‘Delete the record
next
end if
end if
%>
<% Set conn = Server.CreateObject("Adodb.Connection") conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("Adodb.Recordset") rs.open "Discuss",conn,1,3 do while not rs.eof response.write(" " " " " rs.movenext loop rs.close set rs = nothing set conn = nothing %>
User Title Post Date " & _ ") " & rs.fields("User") & " " & _ " & rs.fields("Title") & " " & _ " & rs.fields("PostDate") & " " & _
Copyright © 2001-02 ISC Software. All rights reserved. All other product and brand names are registered properties of their respective owners.