Sample set to connect my Access database with OLE DB?

Source: Internet
Author: User
Tags compact ole access database
Before you begin your should check to make sure this you have MDAC v2.1 SP2 or later on installed. To get the latest MDAC goto http://www.microsoft.com/data. If you are are unsure which version of MDAC you have installed Microsoft provides a tool called ComCheck which'll tell you.

A basic OLE DB Connection String looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb"
Course you'll have to replace the path above ("C:\Db1.mdb") with the path and filename of your own database. If the database is located on a ISP ' s server and you don ' t know the physical path of your database can use the server . Mappath () function. Eg:
"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("/db1.mdb") However it is not recommended Lace your database in a folder that has IIS Read permissions enabled (as any casual web-browser would be able to download t He file if the filename is known).

It is recommended this assign your connection string to a application level global variable or create a include file that contains code, that assigns the connection string to a, local variable, with the include file being in each P Age that requires a database connection). This way if your database ever changes your only need to make one change to your code to enable it to connect to your new D Atabase.
Eg (in your Global.asa):
Sub Application_OnStart
Application ("strdbconnectionstring") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db1.mdb"
End Sub
You could need to specify additional parameters for the connection string (eg a User ID and Password, if you have placed a U Sername/password restriction on the database).

The following is a list of additional parameters which can go into the connection string. Each parameter takes the form of:

Parameter Name=value
and is separated from the next parameter by A;

User ID (Default:user id=admin)
Password (default:password= "")
Mode
Extended Properties
Jet Oledb:system
Jet Oledb:registry Path
Jet Oledb:database Password
Jet Oledb:engine Type
Jet oledb:database Locking Mode
Jet Oledb:global Partial Bulk Ops
Jet Oledb:global Bulk Transactions
Jet oledb:new Database Password
Jet oledb:create System Database
Jet Oledb:encrypt Database
Jet Oledb:don ' t Copy Locale on Compact
Jet oledb:compact without Replica Repair
Jet OLEDB:SFP

For a comprehensive list of connection strings (Access or otherwise) check out this page over at able
Consulting.


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.