Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2001

    Unanswered: how to use VB ActiveX and DB2

    Hi all,

    Im a relative newbie to VB and I am having big troubles trying to connect to an AS/400 database using VB 6.0 code. All I want to do is call a program on the AS400 using my VB code, pass it some paramters and receive some outputs in return. However when I try to call the program all I get is "Wrong number of paramters". I think my problem lies with this line with TUTR32A being the program I need to call:
    IBMCommand.CommandText = "CALL TMOPGM/TUTR32A(?,?,?,?,?,?,?,?,?,?)". My code is attached below.

    Can someone tell me the exact syntax to call an AS400 program in VB?

    Many thanks to anyone if you can provide help!


    Option Explicit
    Public cnIBMSYS01 As New ADODB.Connection

    Public IBMCommand As New ADODB.Command

    Dim EndOfDeclares As String 'keeps comments from floating

    Public Sub Connect()
    cnIBMSYS01.Open "Data Source=IBMSYS01", "ws323", "ws323"
    End Sub

    Public Sub Prepare()
    'NOTE - The Toolkit will add and remove code between markers. Do not comment or delete the lines between the markers.


    Set IBMCommand.ActiveConnection = cnIBMSYS01
    IBMCommand.CommandText = "CALL TMOPGM/TUTR32A(?,?,?,?,?,?,?,?,?,?)"
    IBMCommand.Prepared = True
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("CustNo", adChar, adParamInput, 9)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("CusTax", adChar, adParamInput, 1)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("CusCl", adChar, adParamInput, 2)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("PDisct", adChar, adParamInput, 2)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("TDisct", adChar, adParamInput, 2)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("Item", adChar, adParamInput, 10)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("CusPrc", adNumeric, adParamInputOutput, 7)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("DisPct", adNumeric, adParamInputOutput, 4)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("TaxAmt", adNumeric, adParamInputOutput, 7)
    IBMCommand.Parameters.Append IBMCommand.CreateParameter("UseOld", adChar, adParamInput, 1)
    IBMCommand.Parameters(6).Precision = 5
    IBMCommand.Parameters(6).NumericScale = 2
    IBMCommand.Parameters(7).Precision = 5
    IBMCommand.Parameters(7).NumericScale = 2
    IBMCommand.Parameters(8).Precision = 5
    IBMCommand.Parameters(8).NumericScale = 2
    End Sub

    Public Sub Execute()
    Dim Rcds As Variant
    Dim Parms As Variant
    Dim bahText As String

    'Dim errLoop As Error
    'Dim errLoop As ADODB.Error
    'Parms = Array("511920000", " ", " ", " ", " ", "58801056")

    'Parms = Array("511920000", " ", " ", " ", " ", "58801056", "0000000", "0000", "0000000", " ")
    bahText = IBMCommand.Parameters.Count
    MsgBox bahText
    On Error GoTo ErrHandler
    cnIBMSYS01.Execute IBMCommand.CommandText

  2. #2
    Join Date
    Jan 2003

    check the VB Code and DB Procedures....


    Just check the number of parameters, datatype of parameters are correctly specified and match with DB Procedure.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts