sqlvb.netibm-midrangewindows-task-scheduler

Run VB Application in Windows Task Scheduler


I have an application that have a function same as DTS (transfer data from AS400 to SQL Server). I need this application to run according to a schedule that I made. This application runs normally if I open it, but if I put it in Task Scheduler, it always shows an error:

ERROR [HY000][IBM][System i Access ODBC Driver]Missing system name needed for connection.

This is the script that I use to make a connection to AS400. It runs without error if I run it normally (not in scheduler). Does anyone know how to fix it?

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

Solution

  • your program dont found your ini file, or inifile not contain your connexion informations. Already try to put your inifile in same directory of your exe, else try to write directly you connexionstring into your program for test.