明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

用ASP打開遠(yuǎn)端MDB

[摘要]如果你用ODBC connection (DSN or DSN-less)來訪問遠(yuǎn)端的(UNC path)數(shù)據(jù)庫, OLEDB會(huì)出現(xiàn)以下錯(cuò)誤信息: Microsoft OLE DB Provider for ODBC Drivers error ’80004005’ [Microsoft][ODB...

如果你用ODBC connection (DSN or DSN-less)來訪問遠(yuǎn)端的(UNC path)數(shù)據(jù)庫, OLEDB會(huì)出現(xiàn)以下錯(cuò)誤信息:

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.


你完全可以避免這種錯(cuò)誤--ASP和ActiveX支持兩種方式打開MDB文件的DSN-less連接,或由其它機(jī)器訪問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的數(shù)據(jù)庫及共享訪問權(quán)限。

假定有權(quán)限的話,你亦可訪問其它機(jī)器中的開放數(shù)據(jù)連接:


http://www.pstruh.cz/

Set UM = CreateObject("UserManager.Server")

UM.LogonUser "Login with the rights", "Password", "Domain"

...

open database

...

UM.RevertToSelf (出處:Viphot)