|
本帖最后由 najagay 于 2015-8-24 00:47 编辑
我通过以下代码打开制定的access2007文件,可在winxp, vb6.0, word2007中打开数据库时,在 cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DatabasePath 地方出现“实时错误 -2147217843(80040E4d)验证失败”的错误信息?
这个问题怎么解决?
Function ConnectDB(DatabasePath As String) As Boolean
Public cn As ADODB.Connection '定义一个ADODB连接数据库
Public rs As ADODB.Recordset
DatabasePrepared = False
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DatabasePath
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "Select * from Namsiz", cn, adOpenStatic, adLockReadOnly, adCmdText
Set rs.ActiveConnection = Nothing
cn.Close
ConnectDB = True
DatabasePrepared = True
End Function
|
|