首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Excel VBA -与Teradata的连接字符串不起作用

Excel VBA -与Teradata的连接字符串不起作用
EN

Stack Overflow用户
提问于 2016-04-29 00:40:04
回答 1查看 855关注 0票数 0

我已经在Excel VBA中创建了一个工具,用于连接到Teradata并获取采购订单详细信息。它在我的笔记本电脑上工作正常,但当我与其他人共享该工具时,下面的连接字符串无法连接。在他们的笔记本电脑上进行故障排除时,我看到用户能够使用SQL助手连接到Teradata。但是Excel VBA字符串根本不连接。

below函数运行,CN.state始终返回“0”

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2016-04-30 04:46:59

我有一些问题要问你: 1.其他域中的用户是否需要使用不同的连接字符串? 2.当他们尝试连接时,您会收到什么错误?我在上面的代码中看不到任何错误处理。3.我看到你指定了一个非常短的超时时间。你试过加长它吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36920658

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档