Use ASP to query Access databases

Source: Internet
Author: User
---- This article focuses on accessing the Access database through ASP script language in IIS4.0 service management. As to how to create a system DSN, you can try it yourself.
---- First, create an Access database with the name, department name, and department fee.
---- Next, on the WWW server where IIS4.0 is installed, open ODBC, create the system DSN, data source name ABC, select the corresponding Access database, and then you can start writing ASP Programs.
---- As needed, we want to query the department names in the Access database by different departments and by the amount of fees.
---- Query shujuku5.asp by department name. The source code of the ASP program is as follows:
<Html>
<Body>
<%
Set Connect = Server. CreateObject ("ADODB. Connection ")
Connect. Open "abc"
S = Request ("menu1 ")
SQL = "select * from sheet1 where
Department name = "&" "& s &""
Set rs = Connect. Execute (SQL)
%>
<Table border = 1 cellspacing = 1>
<Tr bgcolor = "#00 ffff">
& Lt; % For I = 0 TO 7% & gt;
<Td size = 1> <B> <% = rs (I). Name %> </B>
<Td> <% Next %>
<Tr>
<% Do While Not rs. EOF %>
<Tr>
& Lt; % For I = 0 TO 7% & gt;
<Td size = 1> <% = rs (I) %> <td>
<% Next %>
</Tr>
<% Rs. MoveNext
Loop
%>
<%
Rs. Close
Connect. Close
%>
</Table>
</Body>
</Html>
---- Create shujuku4.asp according to the charge amount. The ASP Source Code program is as follows:
<Html>
<Body>
<%
Set Connect = Server. CreateObject ("ADODB. Connection ")
Connect. Open "ABC"
R = Request ("textfield ")
S = Request ("menu2 ")
If s = "greater than" then
SQL = "select * from sheet1 where charge amount>" & r &"
Elseif s = "less than" then
SQL = "select * from sheet1 where charge amount <" & r & ""

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.