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

    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!

    Nathan
    ncreswell@dc.com


    Option Explicit
    '{{DA400_CONNECTIONS_BEGIN}}
    Public cnIBMSYS01 As New ADODB.Connection
    '{{DA400_CONNECTIONS_END}}

    '{{DA400_PROGRAMS_BEGIN}}
    Public IBMCommand As New ADODB.Command
    '{{DA400_PROGRAMS_END}}

    Dim EndOfDeclares As String 'keeps comments from floating

    Public Sub Connect()
    '{{DA400_CONNECTS_BEGIN}}
    cnIBMSYS01.Open "Data Source=IBMSYS01", "ws323", "ws323"
    '{{DA400_CONNECTS_END}}
    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.

    '{{DA400_PROGRAM_PREPARES_BEGIN}}

    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
    '{{DA400_PROGRAM_PREPARES_END}}
    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
    '{{DA400_PROGRAM_EXECUTES_BEGIN}}
    '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
    Posts
    4

    check the VB Code and DB Procedures....

    Hi

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

    Cheers,
    Vijay.

Posting Permissions

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