如果你用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