我已经在Excel VBA中创建了一个工具,用于连接到Teradata并获取采购订单详细信息。它在我的笔记本电脑上工作正常,但当我与其他人共享该工具时,下面的连接字符串无法连接。在他们的笔记本电脑上进行故障排除时,我看到用户能够使用SQL助手连接到Teradata。但是Excel VBA字符串根本不连接。
below函数运行,CN.state始终返回“0”
Function Connect(Server As String, Database As String) As Boolean
Set CN = New ADODB.Connection
On Error Resume Next
Dim UserId As String
Dim Password As String
Call CenterLoginWindow
'Input UserID and Password here
UserId = Login.Username
Password = Login.Password
With CN
' Create connecting string
.ConnectionString = "Data Source=" & Server & ";" & _
"Database=" & Database & ";" & _
"Persist Security Info=True;Session Mode=ANSI;" & _
"Uid=" & UserId & ";" & _
"Pwd=" & Password & ""
.CommandTimeout = 0
' Open connection
.Open
End With
' Check connection state
If CN.State = 0 Then
Connect = False
Else
Connect = True
End If
End Function发布于 2016-04-30 04:46:59
我有一些问题要问你: 1.其他域中的用户是否需要使用不同的连接字符串? 2.当他们尝试连接时,您会收到什么错误?我在上面的代码中看不到任何错误处理。3.我看到你指定了一个非常短的超时时间。你试过加长它吗?
https://stackoverflow.com/questions/36920658
复制相似问题