This article discusses ASP, not the. aspx that is written by Visual Studio, which is ASP.
ASP does not need any plug-in support, the key you are the configuration of Windows IIS server, the page is thrown on the above to execute.
IIS server configuration for different Windows systems, in addition to some castrated WinXP installed systems, support the IIS server configuration, in the Windows components, do not need to download anything. How to configure the IIS server is not the focus of this article.
I. BASIC OBJECTIVES
Suppose the table test exists in Access2007 database Database.mdb as follows:
ID is a self-increment column, Username,password are text
It is now required to query this form in the ASP page. And then continue to add a username=3,password=a content.
When you run an ASP webpage, remember to turn access off, and you can't run an ASP page while you open access.
Second, the production process
ASP code must be written in <%%>,
The ASP declaration variable can be used in dim A; Declaration, a is not type, the system automatically recognizes. Dim can not write, that is, completely can write a= what,
Changing the value of a must be set a=. Cannot directly a= ..., this is the initialization of a.
The value of the Database Declaration Section Conn and RS must be given in the form of Set Conn, because the system has been initialized automatically.
The
The code for the entire page is as follows, as described in the following paragraph:
This code is to use Notepad to knock out, without any development tools, all lack of indentation and other basic code format forgive me, ASP is lack of code development tools.Aspedit are some of the things that have been published for 1997 years.
1.
Here's the <body> section.
2. Connect to the Database section
<% ' ASP with ' use ' to comment, not allowed; To end the statement, each enter key is the end of a statement "Access database file is database.mdbdb=" Database.mdb "Set conn = Server.CreateObject ("ADODB. Connection ") ' Specifies the action, and the value after PWD represents the password conn for this database. Open "Driver={microsoft Access driver (*.mdb)};p wd=admin;dbq=" & Server.MapPath (db) to output something on a Web page, you can use the Response object Response.Write "Database connection was successful! "%>
3. Query Part<% ' Specifies the action set rs = Server.CreateObject ("ADODB. Recordset ") ' query statement sql =" SELECT * from Test; "' Using SQL to query conn, the following parameters represent I want to fully manipulate the database Rs.Open sql,conn,1,3%><!--This is the table header, ASP code can be mixed with HTML code, table default is no border, So to set a border parameter--><br/> the contents of the table test: <table border= "1" > <tr> <td>id</td> <td>username</td> <td>password</td> </tr><% ' If you don't find anything to write like that, The ASP has no parentheses, the condition body must end with an end if, then an opening parenthesis, and an end if equivalent to a closing parenthesis if (RS.BOF and rs.eof) thenresponse.write "nodata!" Else ' Otherwise, loop until the cursor is read, the loop condition is not rs.eof,asp without parentheses, the Do While loop body must be closed with loop, the Do while with the left parenthesis, loop equivalent to the closing parenthesis ' HTML loop once to write to the Web page once do While not rs.eof%> <tr> <td><%=rs ("id")%></td> <td><%=rs (" Username ")%></td> <td><%=rs (" password ")%></td> </tr> <% ' After reading an item, the cursor pulls down rs.movenextloopend if%></table>
4, add, delete, modify the operation partThe delete operation is not written here, and the modification is commented out, but they are used exactly the same as the increment operation.
<% ' Unlike the query operation, the insert operation is brief. The modify operation can use the following statement to change the item in the Username field (column) of the test table to a 2 ' conn.execute "Update test set Username= ' 2 ' where username= ' a ';" Conn.execute "INSERT into Test (Username,password) VALUES (' 3 ', ' a ');" %>
The reason for querying again after inserting is the same as when the above is not inserted, it is no longer explained.
The "ASP" ASP's connection to access database, the increment and deletion check and the basic syntax of ASP