1-Hour ASP Primer

Source: Internet
Author: User
Tags contains mdb database client
<%
Statement
......
%>
<2> Define Variable Dim statement
<%
Dima,b
a=10
b= "ok!"
%>
Note: The defined variable can be a numeric type, or it can be a character or other type of
<3> Simple Control Process statement
1.If condition 1then
Statement 1
ElseIf condition 2then
Statement 2
Else
Statement 3
endif
2.while conditions
Statement
Wend
3.forcount=1tonstepm
Statement 1
Exitfor
Statement 2
Next
Two. asp Database Simple * Tutorial
<1&gt. Database connection (used to separate the connection file conn.asp)
<%
Setconn=server.createobject ("ADODB.") Connection ")
Conn. Open "Driver={microsoftaccessdriver (*.mdb)};D bq=" &server.mappath
("\bbs\db1\user.mdb")
%>
(Used to connect the User.mdb database in the bbs\db1\ directory)
<2> displaying database records
Principle: Display the record one by one in the database to the client browser, read out each record in the database in turn
If it's from the beginning to the end: Use the loop and determine if the pointer is in use: notrs.eof
If it's from the end of the head: loop and determine if the pointer is starting to work: Notrs.bof

<!--#includefile =conn.asp--> (contains conn.asp to open the User.mdb data in the bbs\db1\ directory
Library
<%
Setrs=server. CreateObject ("Adodb.recordset") (Create a Recordset object)
Sqlstr= "Select*frommessage"----> (message is a data table in the database that you want to display
Data tables that are stored in the data
rs.opensqlstr,conn,1,3----> (indicates how the database is opened)
Rs.movefirst----> (move pointer to first record)
whilenotrs.eof----> (judging whether the pointer is to the end)
Response.Write (RS ("name"))----> (Display the Name field in the data table message)
Rs.movenext----> (move pointer to next record)
Wend----> (end of Loop)
------------------------------------------------------
Rs.close
Conn.close These sentences are used to close the database
Setrs=nothing
Setconn=nothing
-------------------------------------------------------
%>
Where the response object is the information that the server sends to the client browser
<3> Increase database records
Add database records to rs.addnew,rs.update two functions
<!--#includefile =conn.asp--> (contains conn.asp to open the User.mdb data in the bbs\db1\ directory
Library
<%
Setrs=server. CreateObject ("Adodb.recordset") (Create a Recordset object)
Sqlstr= "Select*frommessage"----> (message is a data table in the database that you want to display
Data tables that are stored in the data
rs.opensqlstr,conn,1,3----> (indicates how the database is opened)
Rs.addnew Add a new record
RS ("name") = "XX" passes the value of XX to the Name field
Rs.update Refresh the database
------------------------------------------------------
Rs.close
Conn.close These sentences are used to close the database
Setrs=nothing
Setconn=nothing
-------------------------------------------------------

%>
<4> Delete a record
Deleting database records is mainly used to rs.delete,rs.update
<!--#includefile =conn.asp--> (contains conn.asp to open the User.mdb database in the bbs\db1\ directory)

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.