用ASP開啟遠端MDB檔案的方法 (轉)

worldblog發表於2007-12-12
用ASP開啟遠端MDB檔案的方法 (轉)[@more@]如果你用OC connection (DSN or DSN-less)來訪問遠端的(UNC path), OLEDB會出現以下錯誤資訊:

OLE DB Provr for ODBC s 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 pession to view its data.


  你完全可以避免這種錯誤--和支援兩種方式開啟MDB的DSN-less連線,或由其它機器訪問MDB檔案。


1. DAO database (only for small load)


Dim File, Conn, RS

Const ReadOnly = False

File = "serversharefile.mdb"

Set Conn = Create("DAO.DBEngine.35").Workspaces(0).OpenDatabase(File,,ReadOnly)

Set RS = Conn.OpenRecordset()


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的資料庫及共享訪問。

假定有許可權的話,你亦可訪問其它機器中的開放資料連線:


Set UM = CreateObject("UserManager.Server")

UM.LogonUser "Login with the rights", "Pass", "ain"

...

open database

...

UM.RevertToSelf


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-992370/,如需轉載,請註明出處,否則將追究法律責任。

相關文章