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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.