用ASP打开远端MDB文件的方法
程序员文章站
2023-11-12 15:12:52
如果你用odbc connection (dsn or dsn-less)来访问远端的(unc path)数据库,&nbs...
如果你用odbc connection (dsn or dsn-less)来访问远端的(unc path)数据库, oledb会出现以下错误信息:
microsoft ole db provider for odbc drivers error '80004005'
[microsoft][odbc microsoft access driver] the microsoft jet database engine cannot open the file '(unknown)'. it is already opened exclusively by another user, or you need permission to view its data.
你完全可以避免这种错误--asp和activex支持两种方式打开mdb文件的dsn-less连接,或由其它机器访问mdb文件。
1. dao database (only for small load)
dim file, conn, rs
const readonly = false
file = "\\server\share\file.mdb"
set conn = createobject("dao.dbengine.35").workspaces(0).opendatabase(file,,readonly)
set rs = conn.openrecordset(sql)
2. ado + jet ole db provider
dim conn, rs
set conn = createobject("adodb.connection")
conn.provider = "microsoft.jet.oledb.4.0"
conn.open "\\server\share\file.mdb"
set rs = conn.execute(sql)
你得确定使用asp的用户有nt的数据库及共享访问权限。
假定有权限的话,你亦可访问其它机器中的开放数据连接:
'http://www.pstruh.cz
set um = createobject("usermanager.server")
um.logonuser "login with the rights", "password", "domain"
...
open database
...
um.reverttoself
microsoft ole db provider for odbc drivers error '80004005'
[microsoft][odbc microsoft access driver] the microsoft jet database engine cannot open the file '(unknown)'. it is already opened exclusively by another user, or you need permission to view its data.
你完全可以避免这种错误--asp和activex支持两种方式打开mdb文件的dsn-less连接,或由其它机器访问mdb文件。
1. dao database (only for small load)
dim file, conn, rs
const readonly = false
file = "\\server\share\file.mdb"
set conn = createobject("dao.dbengine.35").workspaces(0).opendatabase(file,,readonly)
set rs = conn.openrecordset(sql)
2. ado + jet ole db provider
dim conn, rs
set conn = createobject("adodb.connection")
conn.provider = "microsoft.jet.oledb.4.0"
conn.open "\\server\share\file.mdb"
set rs = conn.execute(sql)
你得确定使用asp的用户有nt的数据库及共享访问权限。
假定有权限的话,你亦可访问其它机器中的开放数据连接:
'http://www.pstruh.cz
set um = createobject("usermanager.server")
um.logonuser "login with the rights", "password", "domain"
...
open database
...
um.reverttoself
上一篇: SQL 查询和删除重复字段数据的方法
下一篇: SQL cursor用法实例