[dba-VB] Calling SQL Stored Procedure From Visual Basic 6

Christian, Lorraine LChristian at MassMutual.com
Wed Dec 31 12:15:45 CST 2003

Hi there!

Not be near my source code.  Would something like this help?

Public Sub AutoNumber()
    Dim cmd As New ADODB.Command
    cmd.ActiveConnection = myConn2
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "NBPHI.NEXT_INTVW_ID_NR"
    cmd.Parameters.Append cmd.CreateParameter(, adInteger, adParamOutput)
    cmd.Parameters.Append cmd.CreateParameter(, adInteger, adParamOutput)
    iErrorResponse = cmd.Parameters(0).Value
    If cmd.Parameters(0).Value = 0 Then
        intKey = cmd.Parameters(1).Value
        MsgBox "An error occured creating this record.  Contact your support", vbCritical
    End If

End Sub



Happy New Year
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com]On Behalf Of Francisco H
Sent: Wednesday, December 31, 2003 12:35 PM
To: paul.hartland at fsmail.net; dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Calling SQL Stored Procedure From Visual Basic 6

paul.hartland at fsmail.net wrote:

>To all,
>I am currently writing a visual basic application with which the back-end will be on SQL Server 7.0.  I currently have a data environment with a command object that links to a stored procedure on the SQL Server.  What I want to be able to do is do away with the DataEnvironment and execute the stored procedure from a module and pass the results (i.e. if I had a SELECT SP into a recordset.
>Anyone any ideas how to do this.
>Thanks in advance.
>Paul Hartland
Use ADO.
for help on ADO check your online help, MSDN or


dba-VB mailing list
dba-VB at databaseadvisors.com

This e-mail transmission may contain information that is proprietary, privileged and/or confidential and is intended exclusively for the person(s) to whom it is addressed. Any use, copying, retention or disclosure by any person other than the intended recipient or the intended recipient's designees is strictly prohibited. If you are not the intended recipient or their designee, please notify the sender immediately by return e-mail and delete all copies. 


More information about the dba-VB mailing list