Announcement

Collapse
No announcement yet.

Call remote procedure on AS400 from VBS.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Call remote procedure on AS400 from VBS.

    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:
    Code:
    CALL INSCLI.RUN_PROBE('PARSER','RESULT');
    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


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


  • #2
    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.

    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

    Comment


    • #3
      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".

      Comment

      Working...
      X