Beginner asp: Getting Started experience talk

Source: Internet
Author: User
Tags object end mdb database variable client
Beginner's Experience | Getting Started | a brief introduction to VBScript grammar

VBScript statement is a kind of scripting language based on VB, mainly for Web server-side program development, we only introduce some simple statements, mainly operating database of several common statements

Identification of the <1>.vbscript

<%
Statement
......
%>

<2> Define Variable Dim statement

<%
Dim a,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 1 Then
Statement 1
ElseIf Condition 2 Then
Statement 2
Else
Statement 3
endif

2.while conditions
Statement
Wend

3.for count=1 to n step m

Statement 1
Exit For
Statement 2
Next

  Two. asp database simple Operation 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 (" \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, and then read each record in the database
if it is from beginning to end: Use loops and determine whether the pointer is used at a later time: not rs.eof
If it is from the end: Use loops and determine if the pointer is to start using: No     T Rs.bof

<!--#include file=conn.asp--> (contains conn.asp to open User.mdb database under bbs\db1\ directory)
<%
Set Rs=server. CreateObject ("Adodb.recordset") (Create a Recordset object)
sqlstr= "SELECT * from Message"----> (the message is a data table in the database, The data table in which you want to display the data)
Rs.Open sqlstr,conn,1,3----> (means to open the database)
Rs.movefirst----> (move the pointer to the first record
While not rs.eof----> (To determine if 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----> (Loop end)
-------------------------     -----------------------------
Rs.close
conn.close These sentences are used to close the database
set rs=nothing
    Set conn=nothing
-------------------------------------------------------
%>
Where the response object is the information that the server sends to the client browser

[1] [2] [3] Next page



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.