ADO连接ACCESS数据库密码问题,救急

justinlove 2001-07-23 02:30:05
加精
我用ADO方式连接ACCESS数据库,想将.mdb文件加上密码,请问怎样打开
set conn=server.createobject("adodb.connection")
DBPath = Server.MapPath("user.asp")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath & ???
...全文
115 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
justinlove 2001-07-23
谢谢,刚才发言的时候你还没有贴呢....,ASP的帮助怎么就那么差,我始终找不到函数的调用方式,只有自己去试,结果试了半天也没有结果...能告诉我ASP详细帮助的从哪里得到吗?
另外再问一句,如果我用上面b) i)的方式,uid一定要填admin吗?
回复
justinlove 2001-07-23
呵呵,这种我以前也看到过,请问有没有我提供的那种方式的调用方法?
回复
tonnycncn 2001-07-23
下面将简单介绍一下几种ado连接方式:odbc dsn,odbc dsn-less,
ole db provider,和"ms remote" provider.
1。odbc dsn连接
i.dsn
oconn.open "dsn=advworks;" & _
"uid=admin;" & _
"pwd=;"
注意:从mdac2.1开始就不能够在使用这样的方式了,就是只把dsn文件名放在connectstring中
你必须同时使用dsn,uid,pwd标志。例如下面的方式在mdac 2.1中将会出错:
oconn.open "advworks"



ii.file dsn
oconn.open "filedsn=\somepath\mydb.dsn;" & _
"uid=admin;" & _
"pwd=;"
iii.odbc dsn-less connections
a)odbc text driver
oconn.open _
"driver={microsoft text driver (*.txt; *.csv)};" & _
"dbq=\somepath\;" & _
"extensions=asc,csv,tab,txt;" & _
"persist security info=false"
注意:需要在sql语句中指定使用到的文件名。例如:
ors.open "select * from customer.csv", _
oconn, adopenstatic, adlockreadonly, adcmdtext
b)odbc driver for access
i)普通安全模式:
oconn.open _
"driver={microsoft access driver (*.mdb)};" & _
"dbq=\somepath\mydb.mdb;" & _
"uid=admin;" & _
"pwd=;"
ii)如果使用了system database:
oconn.open _
"driver={microsoft access driver (*.mdb)};" & _
"dbq=\somepath\mydb.mdb;" & _
"systemdb=\somepath\mydb.mdw;", _
"admin", ""
c)odbc driver for sql server
i)普通安全模式
oconn.open "driver={sql server};" & _
"server=carl2;" & _
"database=pubs;" & _
"uid=sa;" & _
"pwd=;"
ii)使用信任安全模式:
oconn.open "driver={sql server};" & _
"server=carl2;" & _
"database=pubs;" & _
"uid=;" & _
"pwd=;"
注意:要使用空白的uid和pwd
d)odbc driver for oracle
i)使用现有的oracle odbc driver from microsoft:
oconn.open _
"driver={microsoft odbc for oracle};" & _
"server=oracleserver.world;" & _
"uid=demo;" & _
"pwd=demo;"
ii)使用老版本的oracle odbc driver from microsoft:
oconn.open _
"driver={microsoft odbc driver for oracle};" & _
"connectstring=oracleserver.world;" & _
"uid=demo;" & _
"pwd=demo;"
iiii)使用微软的ole db data link connections方式data link file (udl)
a)使用绝对路径
oconn.open "file name=\somepath\pubs.udl;"
b)使用相对路径
oconn.open "file name=pubs.udl;"
v)ole db provider connections方式
a)ole db provider for odbc databases
i)access (jet):
oconn.open _
"provider=msdasql;" & _
"driver={microsoft access driver (*.mdb)};" & _
"dbq=\somepath\mydb.mdb;" & _
"uid=admin;" & _
"pwd=;"
ii)sql server:
oconn.open _
"provider=msdasql;" & _
"driver={sql server};" & _
"server=carl2;" & _
"database=pubs;" & _
"uid=sa;" & _
"pwd=;"
b)ole db provider for microsoft jet (access)
i)普通安全模式:
oconn.open _
"provider=microsoft.jet.oledb.4.0;" & _
"data source=\somepath\mydb.mdb;" & _
"user id=admin;" & _
"password=;"
ii)如果使用了system database:
oconn.open _
"provider=microsoft.jet.oledb.4.0;" & _
"data source=\somepath\mydb.mdb;" & _
"jet oledb:system database=system.mdw;", _
"admin", ""
注意:当使用ole db provider4.0版本是,需要把mdb和mdw文件转换成4.0的数据库格式
iii)如果mdb需要一个数据库密码的话:
oconn.open _
"provider=microsoft.jet.oledb.4.0;" & _
"data source=\somepath\mydb.mdb;" & _
"jet oledb:database password=mydbpassword;", _
"admin", ""
c)ole db provider for excel spreadsheet:
oconn.open _
"provider=microsoft.jet.oledb.4.0;" & _
"data source=\somepath\expenses.xls;" & _
"extended properties=""excel 8.0;hdr=yes;"";"
注意: "hdr=yes"表示在第一行中是行标题,在provider中将不把第一行包括入recordset中
d)ole db provider for sql server
i)普通安全模式:
oconn.open "provider=sqloledb;" & _
"network library=dbmssocn;" & _
"data source=carl2;" & _
"initial catalog=pubs;" & _
"user id=sa;" & _
"password=;"
ii)使用信任安全模式:
oconn.open "provider=sqloledb;" & _
network library=dbmssocn;" & _
"data source=carl2;" & _
"initial catalog=pubs;" & _
"trusted_connection=yes;"
注意:"network library=dbmssocn"声明ole db使用tcp/ip替代named pipes.
e)ole db provider for oracle
oconn.open "provider=msdaora;" & _
"data source=oracleserver.world;" & _
"user id=sa;" & _
"password=;"
(vi)remote ole db provider connections方式(就是我一直在研究的rds方式哦,呵呵。):
a)ms remote - access (jet)
i)odbc dsn:
oconn.open "remote server=http://carl2;" & _
"remote provider=msdasql;" & _
"dsn=advworks;" & _
"uid=admin" & _
"pwd=;"
ii)ole db provider:
oconn.open "provider=ms remote;" & _
"remote server=http://carl2;" & _
"remote provider=microsoft.jet.oledb.4.0;" & _
"data source=\somepath\mydb.mdb;", _
"admin", ""
iii)ole db provider自定义事务对象
oconn.open "provider=ms remote;" & _
"remote server=http://carl2;" & _
"handler=msdfmap.handler;" & _
"data source=myadvworksoledbconnecttag;"
b)ms remote - sql server
i)odbc dsn:
oconn.open "remote server=http://carl2;" & _
"remote provider=msdasql;" & _
"network library=dbmssocn;" & _
"dsn=pubs;" & _
"uid=sa" & _
"pwd=;"
ii)ole db provider
oconn.open "provider=ms remote;" & _
"remote server=http://carl2;" & _
"remote provider=sqloledb;" & _
"network library=dbmssocn;" & _
"data source=carl2;" & _
"initial catalog=pubs;" & _
"user id=sa;" & _
"password=;"
够了吗?^-^

回复
tripofdream 2001-07-23
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath &";Jet OLEDB:Database Password="&pwd
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2001-07-23 02:30
社区公告
暂无公告