ASP getting started 1-hour ASP getting started, very simple
Source: Internet
Author: User
<%
Statement
......
%>
<2> define the dim statement
<%
Dim a, B
A = 10
B = "OK !"
%>
Note: the defined variables can be numeric, character, or other types.
<3> simple control process statements
1. If condition 1 then
Statement 1
Elseif condition 2 then
Statement 2
Else
Statement 3
Endif
2. while condition
Statement
Wend
3. for count = 1 to n step m
Statement 1
Exit
Statement 2
Next
II. Simple ASP database * Tutorial
<1>. Database connection (used to separate the connection file conn. asp)
<%
Set conn = Server. CreateObject ("ADODB. Connection ")
Conn. Open "DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ = "&
Server. MapPath ("bsdb1user. mdb ")
%>
(Used to connect the user. mdb Database in the bbsdb1 directory)
<2> Display database records
Principle: displays the records in the database one by one in the client browser, reads each record in the database in sequence
If it is from start to end: use a loop and determine whether the pointer is used until the end: not rs. eof
If it is from the end to the header: use a loop and determine whether the pointer is used to start using: not rs. bof
<! -- # Include file = conn. asp -->
(Conn. asp is used to open the user. mdb Database in the bbsdb1 directory)
<%
Set rs = server. CreateObject ("adodb. recordset") (create a recordset object)
Sqlstr = "select * from message" ----> (message is a data table in the database, that is, you
The data table that stores the data to be displayed)
Rs. open sqlstr, conn, 1, 3 ----> (indicates how to open the database)
Rs. movefirst ----> (move the pointer to the first record)
While not rs. eof ----> (judge whether the pointer ends)
Response. write (rs ("name") ----> (display the name field in the message Table)
Rs. movenext ----> (move the pointer to the next record)
Wend ----> (loop end)
------------------------------------------------------ Rs. close
Conn. close is used to close the database.
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