1-Hour Introductory ASP

Source: Internet
Author: User

<1> <% Statement ......%>

<2> Define Variable Dim statement

<%Dim a,ba=10b= "ok! "%>// NOTE: The defined variable can be numeric, or it can be a character or other type of

<3> simple control of flow 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 For
Statement 2
Next

Two database operations

<%Set Conn= Server.CreateObject ("ADODB. Connection ") Conn. Open"Driver={microsoft Access DRIVER (*.mdb)}; Dbq= "& Server.MapPath ("\bbs\db1\user.mdb")%>//Database Connection<!--#include file=conn.asp--><%SetRs=server. CreateObject ("Adodb.recordset")//Set up the Recordset object Sqlstr="SELECT * from Message" //(message is a data table in the database, which is the data table that you want to display the data in)Rs.Open sqlstr,conn,1,3//(indicates how the database is opened)Rs.movefirst//(move the pointer to the first record) whileNot rs.eof//(Judging if the pointer is to the end)Response.Write (RS ("Name"))//(Displays the Name field in the data table message)Rs.movenext//(move the pointer to the next record)Wend//(end of cycle)Rs.closeconn.close//These sentences are used to close the databaseSetrs= NothingSetconn= Nothing%>

adding database records

<!--#include file=conn.asp--><%SetRs=server. CreateObject ("Adodb.recordset") (build Recordset object) Sqlstr="SELECT * from Message"//(message is a data table in the database, which is the data table that you want to display the data in)Rs.Open sqlstr,conn,1,3//(indicates how the database is opened)Rs.addnew adds a new record RS ("Name")="XX"Pass the value of XX to the Name field Rs.update Refresh the database rs.closeconn.close//These sentences are used to close the databaseSetrs= NothingSetconn= Nothing%>

Delete a record

<!--#include file=conn.asp--><%Dim NameName="XX"SetRs=server. CreateObject ("Adodb.recordset") (build Recordset object) Sqlstr="SELECT * from Message"Rs.Open Sqlstr,conn,1,3 whileNot rs.eofifRs. ("Name")=name then Rs.Deleters.update//The value of the name field in the Query data table is equal to the value "XX" of the variable name, and if it is met , the deletion is performed.Elseotherwise continue the query until the pointer is to the end Rs.movenextendifWendrs.closeconn.closeSetrs= NothingSetconn= Nothing%>

1-Hour Introductory ASP

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.