Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 21st, 2003, 08:25 AM
Registered User
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB calling DB2 stored procedure

I need to call DB2 stored procedure from my VB application using ADO.
I want to call it directly without using parameter object.
ie by using "Call proc_name param1, param2, ....."
Also the stored procedure has output parameters.
Can anyone suggest how to make this call and how to retrieve the values from the output parameters?

Thanks in advance,
Old July 13th, 2005, 08:55 AM
Registered User
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Here is the code. The procedure executes perfectly but, it does not return the result set!!!!
I'm working on it. Let me know if I'm doing any thing wrong!!!


Private Sub StorProcExecu()
        Dim PROD_ID_CODE As String
        Dim ALT_INV_C As Char
        Dim ELIG_CODE As Char
        Dim CLS_PRC_AMT As Decimal
        Dim DESCRIPTION As String
        Dim OleDbReader As OleDb.OleDbDataReader
        Dim OleDBStr As String = "Provider=""IBMDADB2.1"";Mode=ReadWrite;User ID=XXXXXXX;Data Source=XXXXXXX;Persist " & _
        "Security Info=True;Password=""XXXXXXX"""
        Dim OleDbConn As New OleDb.OleDbConnection(OleDBStr)
        Dim mySelectQuery As String = "call sydb2ft.fbspsm02('042991109',' ',' ','0001-01-01','0001-01-01','0001-01-01',' ',' ','A',' ');"
        'Dim mySelectQuery As String = "SELECT EMPNO FROM A004859.EMP"
        Dim OleDbCmd As New OleDb.OleDbCommand(mySelectQuery, OleDbConn)
        OleDbCmd.CommandType = CommandType.Text

            OleDbReader = OleDbCmd.ExecuteReader(CommandBehavior.CloseConnec tion)
            While OleDbReader.Read()
                PROD_ID_CODE = OleDbReader.Item("PROD_ID_CODE")
                ALT_INV_C = OleDbReader.Item("ALT_INV_C")
                ELIG_CODE = OleDbReader.Item("ELIG_CODE")
                CLS_PRC_AMT = OleDbReader.Item("CLS_PRC_AMT")
                DESCRIPTION = OleDbReader.Item("DESCRIPTION")
            End While
        Catch ex As Exception
        End Try
    End Sub

Similar Threads
Thread Thread Starter Forum Replies Last Post
calling stored procedure jomet JSP Basics 0 November 23rd, 2007 08:06 AM
Calling on a database within a stored procedure Hadware SQL Language 1 January 8th, 2007 05:11 PM
Calling Stored Procedure Using vc++ senthil_mano Visual C++ 0 August 30th, 2006 12:20 AM
Calling Stored procedure in VB.NET kganti VB.NET 2002/2003 Basics 0 March 26th, 2006 08:30 PM
Calling an Oracle Stored Procedure booksnore2 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 October 1st, 2004 09:35 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.