The fourth day of the 10 Day Society ASP

Source: Internet
Author: User
Learning Purpose: Mastering accessDatabasethe connection and read records
What to learn today is a bit boring, but very important. Here we do not need to know the specific operation of the command, outside a lot of books are not suitable for the introduction is because of the introduction of too much theoretical knowledge, so that beginners confused.
Let's go straight to the bottom and see two words:
<%
Set Conn=server.createobject ("Adodb.connection")
Conn.Open "Driver={microsoft Access Driver (*.mdb)};d bq=" &server.mappath ("Example3.mdb")
%>
The first sentence defines a ADODBDatabaseConnectionComponent, the second sentence is connected.Database, you just change the back of theDatabaseName on it. Is it simple?
Look at the next three sentences:
<%
Exec= "SELECT * FROM Guestbook"
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open exec,conn,1,1
%>
These three sentences are added after the first two sentences: Set up the queryDatabasecommand, the Select is followed by the field, if you want to query the words to use the *,from followed by the name of the table, we are established in front of a gustbook table ah? Second sentence: Define a recordsetComponent, all the search records are in here, the third sentence is to open the Recordset, Exec is the query command defined earlier, Conn is the previously definedDatabaseConnectionComponent, followed by the parameter "1,1", which is read, followed by the modified record to set the parameter to 1, 3, OK, next we read the record.
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<%do While not rs.eof%><tr>
<td><%=rs ("name")%></td>
<td><%=rs ("tel")%></td>
<td><%=rs ("message")%></td>
<td><%=rs ("Time")%></td>
</tr><%
Rs.movenext
Loop
%>
</table>
In a table, we use 4 columns to display the last set of four fields, with Do loop, not rs.eof means that the condition is not read to the end of the recordset, rs.movenext means to show a go to the following record,<%=%> is equal to <%response.write%> used to insert ASP code inside the HTML code, mainly for displaying variables.
Well, today is over, we can practice, you can download my example to see, debugging. Here is the picture of the result above my machine.

turn from: Dynamic Network production guide www.knowsky.com


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.