We all know that,ASPIs the abbreviation of Active Server Page, meaning "dynamic Server Page ". ASP is an application developed by Microsoft to replace CGI script programs. It can interact with databases and other programs and is a simple and convenient programming tool. The following describes some basic knowledge for your reference.
1. database connection:
Reference content is as follows:
- <%
- Set conn = server. createobject ("adodb. connection ")
- Conn. open "driver = {microsoft access driver (*. mdb)}; dbq =" & server. mappath ("Database Name ")
- %>
2. Open the database:
Reference content is as follows:
- 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") %>
3. Add a record handler:
Reference content is as follows:
- <%
- 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
- %>
4. Search handler:
Reference content is as follows:
- <%
- 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
- %>
5. Delete record handler:
Reference content is as follows:
- <%
- 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
- %>
6. Modify the record handler:
Reference content is as follows:
- <%
- 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, 3 '1, 3
- Rs ("name") = request. form ("field") 'name, tel, message is the field value set in 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
VII. Example of background login handler:
Reference content is as follows:
- <%
- 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
- %>
I hope that the introduction of the Basic ASP knowledge can help beginners.