|
我之前做的一个access工具里, 加了自动添加ODBC连接串,可是公司系统升级后,ODBC 里的Oracel驱动名称不叫“Oracle in Ora_Client_Home", 也不固定oracle驱动名称了,导致我的程序再也无法在所有电脑的ODBC里自动添加Oracle 的odbc连接串了,我的想法是历遍所有的ODBC驱动名称,将其中有Oracle的放到字符变量里(如str_odbc_driver),然后改为:RegisterDatabase "abcd", str_odbc_driver, True, "Description=China_WareHouse" & vbCr & "ServiceName=oracle0011" & vbCr & "UserName=" & vbCr & "Password=". 但如何历遍还写不出来,请各位大虾指导,非常感谢!
------以下是原代码-----------
ErrorHandler:
If (Err = 3151) Or (Err = -2147467259) Then 'ODBC connection error
nCfmRefresh = MsgBox("ODBC connect error, do you want to refresh linking?", vbYesNo, "Error")
If nCfmRefresh = vbYes Then
RegisterDatabase "abcd", "Oracle in Ora_Client_Home", True, "Description=China_WareHouse" & vbCr & "ServiceName=oracle0011" & vbCr & "UserName=" & vbCr & "Password="
MsgBox "ODBC connection refreshed, Please open program again.Thanks !"
Application.Quit
Else
Application.Quit
End If
Else
MsgBox "Error " & Err & ": " & Err.Description
End If
|
|