0

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
Ry-
  • 218,210
  • 55
  • 464
  • 476
Fauzi Rachman
  • 103
  • 1
  • 2
  • 9
  • 2
    This is a bit of a long shot, but if your connection is defined under your normal user, it may not be visible to the scheduled task user. – Andrew Mortimer Nov 10 '16 at 08:45
  • 1
    Additionally: Try to provide the absolute path of your `config.ini` when calling `_inifile.Baca` – Alex B. Nov 10 '16 at 09:42
  • Alright, when I test to not use an ini file, it works. But why if I use iniFile always shows that error :( should I put the ini file to task scheduler? – Fauzi Rachman Nov 14 '16 at 01:24

1 Answers1

1

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.

Esperento57
  • 16,521
  • 3
  • 39
  • 45