ASP deletion and batch deletion code

Source: Internet
Author: User

<! -- # Include file = "Connections/Conn. asp" -->
<%
Set C. Createobject ("ADODB. Connection ")
Conn. c
Conn. Open
Set COM = server. Createobject ("ADODB. Command ")
Com. commandtext = "delete from portal_articles where ArticleID =" + request. querystring ("ArticleID ")
Com. activec
Com.exe cute ()
Response. Redirect ("admin_articles.asp ")
'Conn.exe cute ("insert into portal_articles (title, author, catid) values ('20170101', 'test', 5 )")
'Conn. Close ()
'Response. Redirect ("admin_articles.asp ")
%>
''Batch Delete Code
<% @ Language = "VBScript" codePage = "936" %>
<Script language = "JavaScript">

Function selectallcheckboxes (spanchk ){

VaR xstate = spanchk. checked;
VaR thebox = spanchk;
Elm = thebox. Form. elements; // obtain all controls in Form
For (I = 0; I <Elm. length; I ++)
If (ELM. Type = "checkbox" & elm. ID! = Thebox. ID)
{

If (ELM. Checked! = Xstate)
Elm. Click ();

}
}
</SCRIPT>

<! -- # Include file = "Connections/Conn. asp" -->
<%
'Get all selected ID strings
Dim myids
Myids = request. Form ("chkid ")

'Detach ID to the array
Dim articleids
Articleids = Split (myids ,",")
'Response. Write (ubound (articleids ))
'Connect to the database
'Response. Write (myids)
Set C. Createobject ("ADODB. Connection ")
Conn. c
Conn. Open
'''''''''''''''''''''''''''''''''''''''' '''
'Cycle to delete the selected ID
Dim I
For I = 0 to ubound (articleids)
Sqlstr = "delete from portal_articles where ArticleID =" + articleids (I)
Conn.exe cute (sqlstr)
'Response. Write (sqlstr + "<br/> ")
Next
Conn. Close
If ubound (articleids)> = 0 then response. Redirect ("admin_articles.asp") 'fixes the bug where the automatic code generated by Dreamweaver still displays the clear record.
%>
 

''Delete Code

<! -- # Include file = "Connections/Conn. asp" -->
<%
Set conn = server. Createobject ("ADODB. Connection ")
Conn. connectionstring = mm_conn_string
Conn. Open
Set COM = server. Createobject ("ADODB. Command ")

Com. commandtext = "delete from portal_articles where ArticleID =" + request. querystring ("ArticleID ")
Com. activeconnection = Conn
Com.exe cute ()
Response. Redirect ("admin_articles.asp ")
'Conn.exe cute ("insert into portal_articles (title, author, catid) values ('20170101', 'test', 5 )")
'Conn. Close ()
'Response. Redirect ("admin_articles.asp ")
%>

''Batch Delete Code

<% @ Language = "VBScript" codePage = "936" %>
<Script language = "JavaScript">

Function selectallcheckboxes (spanchk ){
 
VaR xstate = spanchk. checked;
VaR thebox = spanchk;
Elm = thebox. Form. elements; // obtain all controls in Form
For (I = 0; I <Elm. length; I ++)
If (ELM [I]. type = "checkbox" & elm [I]. ID! = Thebox. ID)
{

If (ELM [I]. Checked! = Xstate)
Elm [I]. Click ();

}
}
</SCRIPT>

<! -- # Include file = "Connections/Conn. asp" -->
<%
'Get all selected ID strings
Dim myids
Myids = request. Form ("chkid ")

'Detach ID to the array
Dim articleids
Articleids = Split (myids ,",")
'Response. Write (ubound (articleids ))
'Connect to the database
'Response. Write (myids)
Set conn = server. Createobject ("ADODB. Connection ")
Conn. connectionstring = mm_conn_string
Conn. Open
'''''''''''''''''''''''''''''''''''''''' '''
'Cycle to delete the selected ID
Dim I
For I = 0 to ubound (articleids)
Sqlstr = "delete from portal_articles where ArticleID =" + articleids (I)
Conn.exe cute (sqlstr)
'Response. Write (sqlstr + "<br/> ")
Next
Conn. Close
If ubound (articleids)> = 0 then response. Redirect ("admin_articles.asp") 'fixes the bug where the automatic code generated by Dreamweaver still displays the clear record.
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.