Call remote procedure on AS400 from VBS.

Home Forums Scripting Windows Script Host Call remote procedure on AS400 from VBS.

This topic contains 2 replies, has 2 voices, and was last updated by Avatar jeff.schumacher 6 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Avatar
    h0ndzik
    Member
    #159789

    Hi all,
    I’m trying call remote procedure with parameters on IBM AS400 DB and I get error down bellow.
    Command works fine, but not from VBS.

    Any idea?
    Best regards

    DB name: INSCLI
    procedure with parameters: RUN_PROBE(‘PARSER’,’RESULT’);

    SQL Command:

    CALL INSCLI.RUN_PROBE(‘PARSER’,’RESULT’);
    [/CODE]

    VBS:
    [CODE]
    Dim Conn: Set Conn = CreateObject(“ADODB.Connection”)
    Conn.Open “PROVIDER=IBMDA400;Trusted_Connection=no;server=10.10.10.10;user id=user;password=pass;DATABASE=INSCLI;”

    Set objCommandSec = CreateObject(“ADODB.Command”)

    With objCommandSec
    Set .ActiveConnection = Conn
    .CommandType = 4
    .CommandText = “RUN_PROBE”
    .Parameters.Append .CreateParameter(“@inVar1”, 200, 1, 255, “PARSER”)
    .Parameters.Append .CreateParameter(“@inVar2”, 200, 1, 255, “RESULT”)
    .Parameters.Append .CreateParameter(“@outVar1”, 200, 2, 255)
    .Parameters.Append .CreateParameter(“@outVar2”, 200, 2, 255)

    .Execute

    msgbox .Parameters(2).Value & “/” & .Parameters(3).Value
    End With

    set objCommandSec = Nothing
    Conn.Close: set Conn = Nothing
    [/CODE][FONT=&quot]

    Error:
    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
    Code:80040E21
    Source:Provider

    [/FONT][CODE]
    CALL INSCLI.RUN_PROBE(‘PARSER’,’RESULT’);
    [/CODE]

    VBS:

    Dim Conn: Set Conn = CreateObject(“ADODB.Connection”)
    Conn.Open “PROVIDER=IBMDA400;Trusted_Connection=no;server=10.10.10.10;user id=user;password=pass;DATABASE=INSCLI;”

    Set objCommandSec = CreateObject(“ADODB.Command”)

    With objCommandSec
    Set .ActiveConnection = Conn
    .CommandType = 4
    .CommandText = “RUN_PROBE”
    .Parameters.Append .CreateParameter(“@inVar1”, 200, 1, 255, “PARSER”)
    .Parameters.Append .CreateParameter(“@inVar2”, 200, 1, 255, “RESULT”)
    .Parameters.Append .CreateParameter(“@outVar1”, 200, 2, 255)
    .Parameters.Append .CreateParameter(“@outVar2”, 200, 2, 255)

    .Execute

    msgbox .Parameters(2).Value & “/” & .Parameters(3).Value
    End With

    set objCommandSec = Nothing
    Conn.Close: set Conn = Nothing
    [/CODE][FONT=&quot]

    Error:
    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
    Code:80040E21
    Source:Provider

    [/FONT][CODE]
    Dim Conn: Set Conn = CreateObject(“ADODB.Connection”)
    Conn.Open “PROVIDER=IBMDA400;Trusted_Connection=no;server=10.10.10.10;user id=user;password=pass;DATABASE=INSCLI;”

    Set objCommandSec = CreateObject(“ADODB.Command”)

    With objCommandSec
    Set .ActiveConnection = Conn
    .CommandType = 4
    .CommandText = “RUN_PROBE”
    .Parameters.Append .CreateParameter(“@inVar1”, 200, 1, 255, “PARSER”)
    .Parameters.Append .CreateParameter(“@inVar2”, 200, 1, 255, “RESULT”)
    .Parameters.Append .CreateParameter(“@outVar1”, 200, 2, 255)
    .Parameters.Append .CreateParameter(“@outVar2”, 200, 2, 255)

    .Execute

    msgbox .Parameters(2).Value & “/” & .Parameters(3).Value
    End With

    set objCommandSec = Nothing
    Conn.Close: set Conn = Nothing
    [/CODE][FONT=&quot]

    Error:
    Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
    Code:80040E21
    Source:Provider

    [/FONT]

    #375379

    Re: Call remote procedure on AS400 from VBS.

    Hello, I’m, still trying but no success. Here is new script and error. Any idea?
    Best regards.

    Option Explicit
    Dim objCon, objCom, objPara, objpara2, objpara3, objRS, k

    Set objCon = CreateObject(“ADODB.Connection”)
    Set objCom = CreateObject(“ADODB.Command”)

    objCon.ConnectionString = “Driver={iSeries Access ODBC Driver};System=10.10.10.10;Uid=login;Pwd=password;”

    objCon.Open objCon.ConnectionString

    With objCom
    .CommandText = “CALL INSCLI.RUN_PROBE(‘PARSER’,’RESULT’)”

    .CommandType = 1 ‘Type : stored procedure
    .ActiveConnection = objCon
    End With

    ‘Create 2 output parameters
    Set objPara = objCom.CreateParameter
    With objPara
    .name = “@p1”
    .type = 8
    .Direction = 1
    .Value = “PARSER”
    End With
    Set objpara2 = objCom.CreateParameter
    With objpara2
    .name = “@p2”
    .type = 8
    .Direction = 2
    .Size = 200
    End With

    objCom.Parameters.Append objpara
    objCom.Parameters.Append objpara2

    Set objRS = objCom.Execute

    MsgBox objCom.Parameters.Item(“@p2”).Value

    For k = 0 To objRS.Fields.Count -1
    MsgBox objRS(k).Name & “: ” & objRS(k).Value
    Next

    objRS.MoveNext

    objRS.Close

    MsgBox “Total records returned: ” & objPara.Value
    MsgBox objpara2.Value

    objCon.Close

    Set objCom = Nothing
    Set objCon = Nothing
    Set objPara = Nothing
    Set objpara2 = Nothing
    Set objRS = Nothing
    [/CODE][CODE]
    Option Explicit
    Dim objCon, objCom, objPara, objpara2, objpara3, objRS, k

    Set objCon = CreateObject(“ADODB.Connection”)
    Set objCom = CreateObject(“ADODB.Command”)

    objCon.ConnectionString = “Driver={iSeries Access ODBC Driver};System=10.10.10.10;Uid=login;Pwd=password;”

    objCon.Open objCon.ConnectionString

    With objCom
    .CommandText = “CALL INSCLI.RUN_PROBE(‘PARSER’,’RESULT’)”

    .CommandType = 1 ‘Type : stored procedure
    .ActiveConnection = objCon
    End With

    ‘Create 2 output parameters
    Set objPara = objCom.CreateParameter
    With objPara
    .name = “@p1”
    .type = 8
    .Direction = 1
    .Value = “PARSER”
    End With
    Set objpara2 = objCom.CreateParameter
    With objpara2
    .name = “@p2”
    .type = 8
    .Direction = 2
    .Size = 200
    End With

    objCom.Parameters.Append objpara
    objCom.Parameters.Append objpara2

    Set objRS = objCom.Execute

    MsgBox objCom.Parameters.Item(“@p2”).Value

    For k = 0 To objRS.Fields.Count -1
    MsgBox objRS(k).Name & “: ” & objRS(k).Value
    Next

    objRS.MoveNext

    objRS.Close

    MsgBox “Total records returned: ” & objPara.Value
    MsgBox objpara2.Value

    objCon.Close

    Set objCom = Nothing
    Set objCon = Nothing
    Set objPara = Nothing
    Set objpara2 = Nothing
    Set objRS = Nothing
    [/CODE]

    #375380

    Re: Call remote procedure on AS400 from VBS.

    ERROR: [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0469 – IN, OUT, or INOUT not valid for parameter 2 in procedure RUN_PROBE in INSCLI. Line (50): “Set objRS = objCom.Execute”.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.