在 Windows 任务计划程序中运行 VB 应用程序

问题描述 投票:0回答:1

我有一个与DTS功能相同的应用程序(将数据从AS400传输到SQL Server)。我需要这个应用程序按照我制定的时间表运行。如果我打开这个应用程序,它会正常运行,但是如果我将它放入任务计划程序中,它总是显示错误:

错误 [HY000][IBM][System i Access ODBC 驱动程序]缺少系统名称 需要连接。

这是我用来连接 AS400 的脚本。如果我正常运行它(不在调度程序中),它运行不会出现错误。有谁知道如何解决吗?

Public Sub takeconnectionas400()
    _inifile.Baca("Config.ini", "AS400")
    system = _inifile.system
    uid = _inifile.uid
    pwd = _inifile.pwd
    dbq = _inifile.dbq
    db_as = "Driver={Client Access ODBC Driver (32-bit)};System=" & system & ";Uid=" & uid & ";Pwd=" & pwd & ";Dbq=" & dbq & ""
    conn_as = New OdbcConnection(db_as)
    Try
        If conn_as.State = ConnectionState.Closed Then
            conn_as.Open()
        End If
    Catch ex As Exception
        MsgBox(Err.Description, MsgBoxStyle.Critical, "Error")
    End Try
End Sub
sql vb.net ibm-midrange windows-task-scheduler
1个回答
1
投票

你的程序没有找到你的ini文件,或者ini文件不包含你的连接信息。已经尝试将你的ini文件放在你的exe的同一目录中,否则尝试直接将你的connexionstring写入你的程序中进行测试。

© www.soinside.com 2019 - 2024. All rights reserved.