A Universal Database connection program

Source: Internet
Author: User
I never use a DNS connection, I think that is very inconvenient, the following part of the program can be said to be a universal database connection program can almost connect all the MS database, you take to study it (this program is "ASP Web page Production tutorial" In this book-a good book):
<%
'---------------------------------------------------
Function getmdbconnection (FileName)
Dim Provider, DBPath Provider = "provider=microsoft.jet.oledb.4.0;"
DBPath = "Data source=" & Server.MapPath (FileName)
Set getmdbconnection = getconnection (Provider & DBPath)
End Function '---------------------------------------------------
Function getsecuredmdbconnection (FileName, Password)
Dim Provider, DBPath Provider = "provider=microsoft.jet.oledb.4.0;"
DBPath = "Data source=" & Server.MapPath (FileName)
Set getsecuredmdbconnection = getconnection (Provider & DBPath &); Jet oledb:database password= "& Password)
End Function '---------------------------------------------------
Function getdbcconnection (FileName)
Dim Driver, sourcetype, DBPath Driver = "Driver={microsoft Visual FoxPro Driver};"
SourceType = "SOURCETYPE=DBC;"
DBPath = "sourcedb=" & Server.MapPath (FileName)
Set getdbcconnection = getconnection (Driver & sourcetype & DBPath)
End Function '---------------------------------------------------
Function getdbfconnection (Directory)
Dim Driver, sourcetype, DBPath Driver = "Driver={microsoft Visual FoxPro Driver};"
SourceType = "SOURCETYPE=DBF;"
DBPath = "sourcedb=" & Server.MapPath (Directory)
Set getdbfconnection = getconnection (Driver & sourcetype & DBPath)
End Function '---------------------------------------------------
Function getexcelconnection (FileName)
Dim Driver, DBPath Driver = "Driver={microsoft Excel Driver (*.xls)};"
DBPath = "dbq=" & Server.MapPath (FileName)

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.