How do you execute an Oracle Stored Procedure from Visual Basic 6?

I'm working with an old Visual Basic 6 program.

How do you execute an Oracle Stored Procedure from Visual Basic 6?
AndrewBanferAsked:
Who is Participating?
 
Russ SuterCommented:
Not quite, parameters are added like this:
adoCmd.Parameters.Append adoCmd.CreateParameter(...

Open in new window

where the CreateParameter function declaration looks like this:
adoParamDeclarationAll parameters in CreateParameter are optional but you should at least include a parameter name (which should match the name of the stored procedure parameter) and the value so it would look something like this...
adoCmd.Parameters.Append adoCmd.CreateParameter("[paramname]", , , , [paramvalue])

Open in new window

Again, this is a bit off the top of my head and it's been a while but that should just about do it.
0
 
Russ SuterCommented:
You'll want to use an ADODB connection and command object. The code would look something like this (off the top of my head)
dim adoConn as ADODB.Connection
dim adoCmd as ADODB.Command

set adoConn = new ADODB.Connection
adoConn.Open "[connectionstring]"

set adoCmd = new ADODB.Command
set adoCmd.ActiveConnection = adoConn
adoCmd.CommandText = "[storedprocedurename]"
adoCmd.CommandType = adCmdStoredProc

adoCmd.Execute

Open in new window

Make sure you clean up your object references at the end.
If your stored procedure accepts parameters I believe that's done by calling adoCmd.Parameters.Append ...
0
 
AndrewBanferAuthor Commented:
If the Stored Procedure has parameters would it be like this?

dim adoConn as ADODB.Connection
dim adoCmd as ADODB.Command
dim adoParam as ADODB.Parameter      '(new line)

set adoConn = new ADODB.Connection
adoConn.Open "[connectionstring]"

set adoCmd = new ADODB.Command
set adoCmd.ActiveConnection = adoConn
adoCmd.CommandText = "[storedprocedurename]"
adoCmd.CommandType = adCmdStoredProc
Set adoParam = .CreateParameter(variable1, variable2, variable3, variable4)  'newline
adoCmd.Parameters.Append  'newline


adoCmd.Execute
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.