Database file invocation in ASP development (3)

Source: Internet
Author: User
Tags filter access database
Data | Database The function name in the above code is: Getsqlrecordset, the file name is adosqlfunctions.asp.

You can now use this file to invoke the connection to any Access database, and to filter the table records. Take the Friend.mdb file as an example, listing all the records in table data, with the program code as follows:


!--#include file= "Adovbs.inc"-->
!--#include file= "adosqlfunctions.asp"-->
<%
Dim objRS
Set objrs=getsqlrecordset ("Select number, name, sex from_ data", "Friend.mdb", "data")
Do as Not objrs.eof
Response.Write "No.:" &objrs ("number") & "
"
Response.Write "Name:" &objrs ("name") & "
"
Response.Write "Sex:" &objrs ("Gender") & "
"
Loop

Objrs.close
Set objrs=nothing
Objconn.close
Set objconn=nothing
%>


Summary

In ASP programming, the use of good functions can often be simple to our program code, read the organization is easy to maintain, but also can avoid a lot of duplication of complex code. Like the above case, if it is simply connected to the database, in the first case, the file Adorecordset.asp installed (include) in it, to filter the records of a table in the database or other SQL statement operations, in the second case, It's OK to put the file adosqlrecordset.asp in.



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.