动易网校
| 网站首页 | 系部管理 | 技术文章 | 资料下载 | 人才与社会 | 雁过留声 | 学院论坛 |
程序语言 数据库 电脑艺术 网络技术 软件应用 考试认证
样设置为使用OLEDB连接我的Access数据库?
样设置为使用OLEDB连接我的Access数据库?         
【字体:- +
作者: admin 文章来源:BLOG 点击数: 更新时间:2005-6-13

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

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

The following is a list of additional parameters that 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.


::发表评论::
 姓 名:
 评 分: 1分 2分 3分 4分 5分
 评论内容:
请您发表评论

关于样设置为使用OLEDB连接我的Access数据库?的最新评论:

  • 上一篇文章: 关于ACCESS 2K与ASP的几点想法

  • 下一篇文章: ASP+Access的安全隐患及对策
  • Copyright(C)2005 版权所有:重庆信息技术职业学院--软件工程学院
    Template design to 久久设计 for 1024x768 to MS-IE6 Site powered by powereasy