欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用ASP打开远端MDB

程序员文章站 2022-07-02 14:34:59
如果你用odbc connection (dsn or dsn-less)来访问远端的(unc path), oledb会出现以下错误信息: microsoft ole db provider...
如果你用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 = "\serversharefile.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 "\serversharefile.mdb"

set rs = conn.execute(sql)


你得确定使用asp的用户有nt的数据库及共享访问权限。

假定有权限的话,你亦可访问其它机器中的开放数据连接:


https://www.pstruh.cz/

set um = createobject("usermanager.server")

um.logonuser "login with the rights", "password", "domain"

...

open database

...

um.reverttoself