Method 1:
CopyCode The Code is as follows: Id = request. Form ("checkbox ")
Id = Split (ID ,",")
Shu = 0
For I = 0 to ubound (ID)
SQL = "select * From jiang_fname where id =" & ID (I)
Set rsw.conn.exe cute (SQL)
If not Rs. EOF then
Delete_file (RS ("fname "))
End if
Rs. Close
Set rs = nothing
SQL = "delete from jiang_fname where id =" & ID (I)
Conn.exe cute SQL, Shu1
Shu = Shu + 1
Next
If shu> 0 then
Response. Write ("<SCRIPT> alert ('deleted successfully'); location. href = '" & URL & "'; </SCRIPT> ")
Else
Response. Write ("<SCRIPT> alert ('deletion failed'); javascript: history. Back (); </SCRIPT> ")
End if
Conn. Close
Set conn = nothing
Method 2: Use the in keyword to delete data in batches
Managenews. asp Copy code The Code is as follows: <! -- # Include file = "conn. asp" -->
<% 'I will not say much about the database connection file. %> <HTML>
<Head>
<Title> managing news </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<LINK rel = "stylesheet" href = "../index/style.css" type = "text/CSS">
<SCRIPT>
Function del () // used to determine whether the record has a selected Function
{
VaR flag = true;
VaR temp = "";
VaR TMP;
If (document. form1.answer. Length + "") = "undefined") {TMP = 1} else {TMP = Document. form1.answer. Length}
If (TMP = 1 ){
If (document. form1.answer. Checked ){
Flag = false;
Temp = Document. form1.answer. Value
}
} Else {
For (I = 0; I <document. form1.answer. length; I ++ ){
If (document. form1.answer [I]. Checked ){
If (temp = ""){
Flag = false;
Temp = Document. form1.answer [I]. Value
} Else {
Flag = false;
Temp = temp + "," + document. form1.answer [I]. Value
}
}
}
}
If (FLAG) {alert ("Sorry, you have not selected it yet! ")}
Else {name = Document. form1.name. Value
// Alert (name)
If (confirm ("are you sure you want to delete? ")){
Window. Location = "delnews. asp? Id = "+ temp;
}
}
Return! Flag;
}
</SCRIPT>
</Head>
<Body>
<Script language = JavaScript>
Function checkall (all) // function used to judge all selected records
{
VaR A = Document. getelementsbyname ("Answer ");
For (VAR I = 0; I <A. length; I ++) A [I]. Checked = all. checked;
}
</SCRIPT>
<%
Set rs = server. Createobject ("ADODB. recordset ")
SQL = "select * from news order by addtime DESC"
Rs. Open SQL, Conn, 1,3%>
<% If Rs. EOF then %>
<Table width = "50%" border = "0" align = "center" id = "Table2">
<Tr>
<TD align = "center">
No news!
</Tr>
</Table>
<% Else %>
<Form method = "Post" id = form1 name = form1>
<Table width = "90%" border = "0" align = "center" class = "tabdocborder" id = "table3">
<Tr>
<TD>
<Table width = "80%" align = "center" id = tabdocmain border = '1' cellspacing = '0' cellpadding = '0' bordercolorlight = '# 82b4dd' bordercolor = '# b6d3eb 'class = "tabdocmain">
<Thead>
<Tr>
<TD colspan = "7" align = "center">
News Management Center
</TD>
</Tr>
</Thead>
<Tbody>
<Tr>
<TD align = center>
Delete box
</TD>
<TD align = center>
News Title
</TD>
<TD align = center>
Release Date
</TD>
<TD align = center>
Management
</TD>
</Tr>
<%
Do while not Rs. EOF
%>
"id =" checkbox1 ">
<% if Len (RS (" title ")) <= 30 then %> <% = RS ("title") %> <% else %>
<% = (left (RS ("title "), 30) %>...
<% end if %>
<% = RS ("addtime ") %>
"> editing
<%
Rs. movenext
loop
%>
select all displayed news
<% end if %>
<% set rs = nothing
Conn. close
set conn = nothing
%>
delnews. ASP file copy Code the code is as follows:
<%
arrdel = request (" ID ")
'response. write arrdel
SQL = "delete from news where ID in (" & arrdel & ")"
'response. write SQL
Conn. execute SQL
set conn = nothing
response. write " "
response. End
%>