excel vba中调用SQLConfigDataSource函数时返回值总是FALSE,是哪里出错了?请高手指教!
代码如下:
Private Const ODBC_ADD_SYS_DSN = 4
Private Declare PtrSafe Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Long
Public Function LoadDbSource2(StrDriver, StrAttributes As String) As Boolean
LoadDbSource2 = SQLConfigDataSource(0&, ODBC_ADD_SYS_DSN, StrDriver, StrAttributes)
End Function
Sub hong()
Dim StrAttributes As String
StrAttributes = "DSN=AccessODBC2" & Chr(0) & "Desciption=动态加载ODBC示例" & Chr(0)
StrAttributes = StrAttributes & "Dbq=" & "C:\Users\Administrator\Desktop\180608YearInterestRate.mdb" & Chr(0) & "FIL=MS Access;" & Chr(0)
StrAttributes = StrAttributes & "MaxBufferSize=2048" & Chr(0) & "PageTimeout=5" & Chr(0) & Chr(0)
Call LoadDbSource2("Microsoft Access Driver (*.mdb)", StrAttributes)
End Sub