Basic Knowledge _asp Basics for ASP Novice

Source: Internet
Author: User

As we all know, ASP is an abbreviation for Active Server page, meaning "dynamic servers pages." ASP is an application developed by Microsoft to replace the CGI script program, it can interact with database and other programs, it is a simple and convenient programming tool. Below introduce some basic knowledge, for everybody's reference.

One, database connection

The following are the referenced contents:

<% 
Set Conn=server.createobject ("Adodb.connection") 
Conn.Open "Driver={microsoft Access Driver (*.mdb)}; Dbq= "&server.mappath (" database name ") 
%>

Second, open the database

The following are the referenced contents:

Exec= "SELECT * from database table" 
set Rs=server.createobject ("Adodb.recordset") 
rs.open exec,conn,1,1 

Parameter 1,1 to read

Read content format: <%=rs ("field")%>

Third, add the record processing program

The following are the referenced contents:

<% 
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 the value of the field set for submitting the form 
Tel=request.form ( "Field") 
message=request.form ("field") 
exec= "INSERT into table name (field) VALUES (' + field + ' ')" multiple comma-delimited 
conn.execute exec Use Execute to submit 
conn.close 
set conn=nothing 
%> 

Iv. Search Processing Procedures

The following are the referenced contents:

<% 
name=request.form ("field") Name,tel the value of the field set for submitting the form 
tel=request.form ("field") 
set conn= Server.CreateObject ("Adodb.connection") 
Conn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" & 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 
%> 
' page search leads out <% do while 
not 
rs.eof 
% ><tr> 
<td><%=rs ("name")%></td> 
<td><%=rs ("tel")%></td> 
<td><%=rs ("Time")%></td> 
</tr> 
<% 
rs.movenext 
loop 
% > 

V. Delete a record handler

The following are the referenced contents:

<% 
Set Conn=server.createobject ("Adodb.connection") 
Conn.Open "Driver={microsoft Access Driver (*.mdb) ;d bq= "&server.mappath (database name) 
exec=" Delete * from table name where number = "&request.form (" id ") 
conn.execute EXEC 
%> 

Vi. modification of records processing procedures

The following are the referenced contents:

<% 
Set Conn=server.createobject ("Adodb.connection") 
Conn.Open "Driver={microsoft Access Driver (*.mdb)}; Dbq= "&server.mappath (" database name ") 
exec=" select * from table name where number = "&request.form (" id ") 
set rs= Server.CreateObject ("Adodb.recordset") 
rs.open exec,conn,1,3 ' 1,3 for modification meaning 
rs ("name") =request.form ("field") ' Name,tel,message the field value set for submitting the form 
RS ("tel") =request.form ("field") 
RS ("message") =request.form ("field" 
) Rs.update 
rs.close 
set rs=nothing 
conn.close 
set conn=nothing 
%> 

Modify Record Execution program: enter ID number page >>> export relative ID data >>>>>> directly modified handler

Seven, the background landing processing procedure Example

The following are the referenced contents:

<% 
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)};d bq=" & Server.MapPath ("database name") 
set Rs=server.createobject ("Adodb.recordset") 
rs.open exec,conn 
if not rs.eof Then 
Rs. Close 
Conn. The close session 
("checked") = ' Yes ' session 
(' check ') = ' right ' 
response. Redirect "Index.asp" 
Else session 
("checked") = "No" Session 
("check") = "wrong" 
response. Redirect "Login.asp" End 
if 
%> 

Each background page plus:

<%if not session ("checked") = "yes" Then ' session defines a checked string variable 
response. Redirect "Login.asp"  
else 
%> 

Hope that the above for the ASP basic knowledge of the introduction, can bring some help to beginners.

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.