Implementing Access database Query with ASP

Source: Internet
Author: User
Tags dsn connect access database
access| Data | Database----This paper focuses on accessing the Access database through ASP scripting language implemented in IIS4.0 service management, as to how to create a System DSN. Here and there, interested readers can go and have a try.

----First, create an Access database that contains field names for names, department names, and departmental fees.

----Secondly, on the WWW server installed IIS4.0, open ODBC, create System DSN, data source name ABC, select the corresponding Access database, after the establishment of the ASP program can begin to write.

----as needed, we want to query the department name in the Access database according to the different departments, according to the size of the expense amount.

----The program source code to create shujuku5.asp,asp according to Department name query 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= "#00ffff" >
<%for i=0 to 7% >
< TD size=1 > < b ><%=rs (i). Name% ></b >
< TD ><%next% >
< tr >
<%do while not Rs. eof% >
< tr >
<%for i=0 to 7% >
< TD size=1 ><%=rs (i)% >< td >
<%next% >
</tr >
<%rs. MoveNext
Loop
% >
<%
Rs. Close
Connect.close
% >
</table >
</body >

----Create the Shujuku4.asp,asp source code according to the fee amount 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 fee amount >" &r& ""
ElseIf s= "less than" then
Sql= "SELECT * from Sheet1 where fee amount <" &r& ""
ElseIf s= "equals" then
Sql= "SELECT * from sheet1 where fee amount =" &r& "
ElseIf s= "is greater than or equal to" then
Sql= "SELECT * from Sheet1 where fee amount >=" &r& ""
ElseIf s= "less than equals" then
Sql= "SELECT * from Sheet1 where fee amount < =" &r& ""
End If
Set rs=connect.execute (SQL)
% >
< table border=1 cellspacing=5 >
< tr bgcolor= "#00ffff" >
<%for i=0 to 7% >
< TD >< B >< Font size= "2" ><%=rs (i). Name% >
</font ></b >
< TD ><%next% >
< tr >
<%do while not Rs. eof% >
< tr >
<%for i=0 to 7% >
< TD Size=8 ><%=rs (i)% >< td >
<%next% >
</tr >
<%rs. MoveNext
Loop
% >
<%
Rs. Close
Connect.close
% >
</table >
</body >

----Create a copy of these two ASP files to the IIS4.0 virtual directory wwwroot, and then use FrontPage, Dreamweaver to write an HTML program bumenfeiyong.html, the source code program is as follows:

< HTML >
< head >
< title >untitled document</title >
< meta http-equiv= "content-
Type "content=" text/html; charset=gb2312 ">
< body bgcolor= "#ffffff" >
< div align= "center" >
< p >< B >< font color= "#cc3333" size= "5" >
Departmental fee Inquiries </font ></b ></p >
< P >< img src=http://www.163design.net/a/s/"trees.gif" width= "height=" >
</p >
< table width= "100%" border= "1" cellspacing= "10"
Bordercolor= "#ffffff" >
< tr bordercolor= "#ffcccc" >
< TD height= "9" >
< form method= "POST" action=
"Http://192.1.168.100/shujuku5.asp" >
< select Name= "Menu1" >
< option selected > search by Department </option >
< option > General Manager's Office </option >
< option > Finance Department </option >
< option > Marketing Department </option >
< option > Accessories </option >
< option > Sales </option >
< option > Office </option >
</select >
< input type= "submit" name= "Submission" value= "submitted" >
</form >
</td >
</tr >
< tr bordercolor= "#ffcccc" >
< td height= ">"
< form method= "POST" action=
"Http://192.1.168.100/shujuku4.asp" >
< select Name= "MENU2" >
< option selected > fee amount </option >
< option > Greater than </option >
< option > Greater than = </option >
< option > equals </option >
< option > Less than equals </option >
< option > Less than </option >
</select >
< input type= "text" name= "TextField" size= "a" >
< input type= "submit" Name= "Submit2" value= "Submission" >
</form >
</td >
</tr >
< tr bordercolor= "#ffcccc" >
< TD > </td >
</tr >
< tr bordercolor= "#ffcccc" >
< TD > </td >
</tr >
< tr bordercolor= "#ffcccc" >
< TD > </td >
</tr >
< tr bordercolor= "#ffcccc" >
< TD > </td >
</tr >
< tr Bo



Related Article

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.