How ADO accesses databases in conjunction with HTML

Source: Internet
Author: User
Tags end query access database access
ado| Data | How does the database ASP cooperate with the HTML code to show the results of executing ADO query database data?
  
For a detailed combination of the ASP with Select, CHECKBOX, and radio, please refer to the following: Initialize the Drop-down menu using Dynamic Data, initialize the radio box with Dynamic Data, use Dynamic Data initialization check box, here is a simple introduction.
ASP program code part, first use ADO link to Access database ntopsamp.mdb, under SQL instruction "select * from book" Check
  
Consult all the data in the "book" of the form and send the results of the query back to the RS2 recordset:
  
<%
  
Set conn1 = Server.CreateObject ("ADODB. Connection ")
  
Conn1. Open "dbq=" & Server.MapPath ("Ntopsamp.mdb") & ";D river={microsoft Access Driver (*.mdb)};D riverid=25;fil=ms Access; "
  
Set rs2 = Server.CreateObject ("ADODB. Recordset ")
  
SQLSTR = "SELECT * FROM book"
  
Rs2. Open sqlstr,conn1,1,1
  
%>
  
The result of the query is then combined with the RS2 recordset and the HTML code, which is displayed in the browser.
  
First, merry-go text marquee
  
The client uses a browser to browse the results of the execution of the rs51.asp, merry-go text that moves from right to left. With the merry-go text <Marquee>
  
The HTML code combines ASP code as follows:
  
<marquee><%= rs2 ("title")%></marquee>
  
Where "rs2 (" book title ") Displays the information in the title field of the Book table as merry-go text.
  
Second, text input text
  
The ASP code that combines the text input HTML code text is as follows:
  
<input type=text size=20 value=<%= rs2 ("title")%> >
  
Where value is "rs2 (" book title "), the text is entered as a preset field" book title "Data.
  
Three, multiple lines of text input textarea
  
The ASP code that combines the HTML code < Textarea> entered with multiline text is as follows:
  
<textarea><%= rs2 ("title")%></textarea>
  
Where "rs2 (" book title "), enter multiple lines of text into the preset field" book title "Data.
  
Four, check the checkbox
  
The ASP code that is combined with the checked HTML code checkbox is as follows:
  
<input Type=checkbox <% if Rs2 ("new book") = True then%> Checked <% End If%>> new book
  
It is checked by "if rs2 (" new book ") = True then" Check the value of the field "new book" in the "books" table and, if true, tick (Checked).
  
Five, pictures
  
The HTML code for the picture combines ASP code as follows:
  
">
  
Where "rs2 (" book title ") shows the data for the field" picture "as a picture," ... /rds/"set the picture file path to rds/," ... /"is represented as the path to the previous layer.
  
Six, Super Link
  
The ASP code that combines the hyperlink HTML code <a href...> is as follows:
  
<a href= ". /rds/<%= rs2 ("Introduction")%> "><%= rs2 (" Introduction ")%></a>
  
Where "rs2 (" book title ") Displays the information for the field" Introduction "as a hyperlink.
  
Seven Drop-down menu select
  
The HTML code for the Drop-down menu <SELECT> combines ASP code as follows:
  
<select name= "Sel1" >
  
<% do, not Rs. EOF%>
  
<option value=<% = rs ("title")%>> <% = rs ("title")%>
  
<% Rs. MoveNext%>
  
<% Loop%>
  
</SELECT>
  
Where "rs2 (" book title ") is the field" book title "Data, by"do while not Rs. Eof... loop"cycle and"rs. movenext"
  
Move to the next record, "not Rs. eof"says it hasn't moved to the end, showing all the data from the" book "Table to the Pull-down menu.
  
Eight, the radio radio
  
The ASP code that combines the HTML code Radio of the radio is as follows:
  
<% do, not Rs. EOF%>
  
<input name=ra1 type=radio value= "<% = rs (" title ")%>" ><% = rs ("title")%>

  
<% Rs. MoveNext%>
  
<% Loop%>
  
Where "rs2 (" book title ") is the field" book title "Data, by"do while not Rs. Eof... loop"cycle and"rs. movenext"
  
Move to the next record, "not Rs. eof"indicates that it has not been moved to the end, displaying all the data from the books table to the radio options.

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.