OracleClient Parameters Stored Procedures

G

Guest

With VB 6 I used this piece of code:

dim adoCmd as new Adodb.Command
dim adoParm as new Adodb.Parameter

with adoCmd
.commandText = "OurComp.SaveWidget"
.commandType = adCmdStoredProc

Set adoParm = .CreateParameter("FirstParam", adChar, adParmInput,
Len(pStrFirst), pStrFirst)
.parameters.append adoParm

Set adoParm = .CreateParameter("SecondParam", adChar, adParmInput,
Len(pStrSecond), pStrSecond)
.parameters.append adoParm

.Execute
end with

What would the corresponding code be for ado.net ?
 
J

Jonathan Allen

This is a guess based on how I do it with SQL Server/ADO.Net

Dim oCon As New Data.OracleClient.OracleConnection("User
ID=XXX;Password=XXX;Data Source=XXX")
oCon.Open()
Dim oCommand As New Data.OracleClient.OracleCommand
oCommand.Connection = oCon
oCommand.CommandType = CommandType.StoredProcedure
oCommand.CommandText = "OurComp.SaveWidget"


Dim oParam1 As New OracleClient.OracleParameter
oParam1.ParameterName = "FirstParam"
oParam1.OracleType = OracleClient.OracleType.Char
oParam1.Direction = ParameterDirection.Input
oParam1.Value = pStrFirst
oCommand.Parameters.Add(oParam1)

Dim oParam2 As New OracleClient.OracleParameter
oParam2.ParameterName = "SecondParam"
oParam2.OracleType = OracleClient.OracleType.Char
oParam2.Direction = ParameterDirection.Input
oParam2.Value = pStrSecond
oCommand.Parameters.Add(oParam2)

oCommand.ExecuteNonQuery()

Jonathan Allen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top