Strengthen ASP learning 1

xiaoxiao2021-03-06  96

Read record

It is a bit boring today to learn, but it is very important. Here everyone don't need to know the specific operation of the order. The reason why many books outside is not suitable for entry is because of the introduction of too many theoretical knowledge, so that beginners foggy.

Let's see the mountain, look at two sentences:

<%

Set conn = server.createObject ("adoDb.connection")

Conn.open "driver = {Microsoft Access Driver (* .mdb)}; dbq =" & Server.mappath ("eXample3.mdb")

%>

The first sentence defines an AdoDB

Database Connectivity

Component, the second sentence is connected

Database, everyone will modify the back

The database name is OK. Is not it simple?

Let's see three sentences below:

<%

EXEC = "Select * from guestbook"

SET RS = Server.createObject ("AdoDb.Recordset")

Rs.Open Exec, CONN, 1, 1

%>

These three sentences are added behind the previous sentences, the first sentence: set the inquiry

The database command, SELECT is added to the field, if you have to query, use *, from the back of the table, what is the first to build a Gustbook table? The second sentence: Define a record set

Components, all searched records are placed here, the third sentence is to open this recordset, and EXEC is the query command that the previous definition is, CONN is the front definition.

Database Connectivity

Components, back parameters "1, 1", this is read, then the modification record sets the parameters to 1, 3, and then we read the record.

<% do while not rs.eof%>

<% = rs ("Name")%>

<% = rs ("tel")%>

<% = RS ("Message")%>

<% = RS ("Time")%>

<%

rs.movenext

loop

%>

In a table, we showed the four fields in the last created table with a 4 column, with the DO loop, NOT RS.EOF means that the condition is not to read the record set, RS.MOVENEXT means It is shown to be turned to a record, <% =%> is equal to <% response.write%> Used to insert an ASP code in the HTML code, mainly for display variables.

It's better to come today, everyone can practice more, you can download my example first, debug it. Below is the result picture above my machine.

转载请注明原文地址:https://www.9cbs.com/read-96829.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.034, SQL: 9