Common ASP knowledge points

Source: Internet
Author: User

Database connection:
<%
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("Database Name ")
%>

Open the database:

Exec = "select * from database table"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open exec, Conn, 1, 1
Parameter 1, 1 is read
Read content format: <% = RS ("field") %>
Add record processingProgram:

<%
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("Database Name ")
Name = request. Form ("field") Name, tel, message is the field value set in the submission form
Tel = request. Form ("field ")
Message = request. Form ("field ")
Exec = "insert into Table Name (field) values (';" + field + "';)" separated by commas
Conn.exe cute exec use execute to submit
Conn. Close
Set conn = nothing
%>

Search handler:

<%
Name = request. Form ("field") Name, tel is the field value set for the submission form
Tel = request. Form ("field ")
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("Database Name ")
Exec = "select * from table where name = ';" + field + "'; and Tel =" + Field
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open exec, Conn, 1, 1
%>

'; The content found on the page is exported

<%
Do while not Rs. EOF
%> <Tr>
<TD> <% = RS ("name") %> </TD>
<TD> <% = RS ("tel") %> </TD>
<TD> <% = RS ("time") %> </TD>
</Tr>
<%
Rs. movenext
Loop
%>

Delete record handler:

<%
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("Database Name ")
Exec = "delete * from table name where id =" & request. Form ("ID ")
Conn.exe cute Exec
%>

Modify record handler:

<%
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("Database Name ")
Exec = "select * from table name where id =" & request. Form ("ID ")
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open exec, Conn, '; 1 and 3 are modified
RS ("name") = request. Form ("field") '; Name, tel, message is the field value set for the submission form
RS ("tel") = request. Form ("field ")
RS ("message") = request. Form ("field ")
Rs. Update
Rs. Close
Set rs = nothing
Conn. Close
Set conn = nothing
%>

Modify the record execution program: Enter the ID number page> export the corresponding ID data >>>> directly modify the processing program
Example of background login handler:

<%
Dim name, password
Name = request. Form ("name ")
Password = request. Form ("password ")
Dim exec, Conn, RS
Exec = "select * from table name where (name = ';" & field & "'; and Password = ';" & field &"';)"
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("Database Name ")
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open exec, Conn
If not Rs. EOF then
Rs. Close
Conn. Close
Session ("checked") = "yes"
Session ("check") = "right"
Response. Redirect "index. asp"
Else
Session ("checked") = "no"
Session ("check") = "wrong"
Response. Redirect "login. asp"
End if
%>

Add:

<% If not SESSION ("checked") = "yes" then'; the session defines a checked string variable.
Response. Redirect "login. asp"
Else
%>

Related Article

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.