当前位置: 首页 > 图文教程 > 网络编程 > ASP > 样设置为使用OLEDB连接我的Access数据库?

ASP
一种比较方便的ASP分页程序
用一套论坛程序架设多个论坛
ASP与ASP.NET在COOKIE方面的区别
较长数据无法在Asp页面中取出的三种解决方法
初试WAP之wml+ASP查询
动态网站首页的静态生成方法
使用正则表达式实现模式图片新闻.ASP
让你的WAP网站有更好的兼容性
WAP版的手机号码所在地查询
asp模仿 Lotus Notes 的界面程序
ORACLE920与ASP的连接问题的解决办法
利用SQLSERVER存储过程实现ASP用户身份验证
在ASP中自动创建多级文件夹的函数(使用FSO)
利用instr()函数防止SQL注入攻击
利用XSL和ASP实现XML文档在线编辑
表单对象textarea内容的格式控制(回车、换行、空格)
针对select写了一个通用的option输出函数
ASP无组件BMP汉字生成类+汉字点阵库
时间、空间性能极优的asp无组件上传类
无组件生成BMP验证码

ASP 中的 样设置为使用OLEDB连接我的Access数据库?


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 44 ::
收藏到网摘: n/a

  Before you begin you should check to make sure that you have MDAC v2.1 SP2 or later installed on yourserver. To get the latest MDAC goto http://www.microsoft.com/data. If you are unsure which version of MDAC you have installed Microsoft provides a tool called ComCheck which will tell you.

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.