excel vba中调用SQLConfigDataSource函数时返回值总是FALSE,是哪里出错了?请高手指教! 5C

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

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐