This article introduces some basic knowledge about ASP, which must be known to all ASP newbies. I hope it will be helpful to you, let’s take a look together.
We all know that ASP is the abbreviation of Active Server Page, meaning dynamic server page. ASP is an application developed by Microsoft to replace CGI scripting programs. It can interact with databases and other programs and is a simple and convenient programming tool. The following are some basic knowledge for your reference.
1. Database connection
The following is the quoted content:
- <%
- setconn=server.createobject(adodb.connection)
- conn.opendriver={microsoftaccessdriver(*.mdb)};dbq=&server.mappath(database name)
- %>
2. Open the database
The following is the quoted content:
- exec=select* from database table
- setrs=server.createobject(adodb.recordset)
- rs.openexec,conn,1,1
Parameter 1, 1 is read
Read content format: <%=rs(field)%>
3. Add record processing program
The following is the quoted content:
- <%
- setconn=server.createobject(adodb.connection)
- conn.opendriver={microsoftaccessdriver(*.mdb)};dbq=&server.mappath(database name)
- name=request.form(field)name,tel,message is the field value set by submitting the form
- tel=request.form(field)
- message=request.form(field)
- exec=insertinto table name (field) values ('+field +') multiple separated by commas
- conn.executeexec commits using execute
- conn.close
- setconn=nothing
- %>
4. Search Processor
The following is the quoted content:
- <%
- name=request.form(field)name, tel is the field value set by the submit form
- tel=request.form(field)
- setconn=server.createobject(adodb.connection)
- conn.opendriver={microsoftaccessdriver(*.mdb)};dbq=&server.mappath(database name)
- exec=select*from table wherename='+field+'andtel=+field
- setrs=server.createobject(adodb.recordset)
- rs.openexec,conn,1,1
- %>
- 'The content searched on the page is exported
- <%
- dowhilenotrs.eof
- %><tr>
- <td><%=rs(name)%></td>
- <td><%=rs(tel)%></td>
- <td><%=rs(time)%></td>
- </tr>
- <%
- rs.movenext
- loop
- %>
5. Delete record processing program
The following is the quoted content:
- <%
- setconn=server.createobject(adodb.connection)
- conn.opendriver={microsoftaccessdriver(*.mdb)};dbq=&server.mappath(database name)
- exec=delete*from table name where number=&request.form(id)
- conn.executeexec
- %>
6. Modify the record processing program
The following is the quoted content:
- <%
- setconn=server.createobject(adodb.connection)
- conn.opendriver={microsoftaccessdriver(*.mdb)};dbq=&server.mappath(database name)
- exec=select*from table name where number=&request.form(id)
- setrs=server.createobject(adodb.recordset)
- rs.openexec,conn,1,3'1,3 is the meaning of modification
- rs(name)=request.form(field)'name,tel,message is the field value set by submitting the form
- rs(tel)=request.form(field)
- rs(message)=request.form(field)
- rs.update
- rs.close
- setrs=nothing
- conn.close
- setconn=nothing
- %>
Modify record execution program: Enter ID number page >>> Export corresponding ID data >>>>>>> Directly modify the handler
7. Examples of background login processing programs
The following is the quoted content:
- <%
- dimname, password
- name=request.form(name)
- password=request.form(password)
- dimexec,conn,rs
- exec=select*from table name where(name='&field&'andpassword='&field&')
- setconn=server.createobject(adodb.connection)
- conn.opendriver={microsoftaccessdriver(*.mdb)};dbq=&server.mappath(database name)
- setrs=server.createobject(adodb.recordset)
- rs.openexec,conn
- ifnotrs.eofthen
- rs.Close
- conn.Close
- session(checked)=yes
- session(check)=right
- response.Redirectindex.asp
- else
- session(checked)=no
- session(check)=wrong
- response.Redirectlogin.asp
- endif
- %>
Each background page plus:
- <%ifnotsession(checked)=yesthen's session defines a checked string variable
- response.Redirectlogin.asp
- else
- %>
I hope that the above introduction to the basic knowledge of ASP can bring some help to beginners.