How can I call an Oracle Stored Procedure using ADO? [message #92870] |
Wed, 28 November 2001 11:30 |
Simiyu
Messages: 2 Registered: November 2001
|
Junior Member |
|
|
How can call an Oracle 8i Stored Procedure and pass IN 21 parameters using ADO through Visual Basic 6.0. Any suggestions or sample code will be appreciated. Thanks.
----------------------------------------------------------------------
|
|
|
Re: How can I call an Oracle Stored Procedure using ADO? [message #92874 is a reply to message #92870] |
Thu, 06 December 2001 19:43 |
Satish Shrikhande
Messages: 167 Registered: October 2001
|
Senior Member |
|
|
Execute a procedure with one input and 2 output parameter .
Create or replace PROCEDURE GET_USER_NAME
(
userid in number,
firstname out varchar2,
lastname out varchar2
)
as
Begin
select last_name, first_name
into lastname,firstname
from t_cms_user where user_id = userid;
end;
============
Private Sub Command1_Click()
Dim objConn As New ADODB.Connection
Dim objRec As New ADODB.Recordset
Dim objComm As New ADODB.Command
Dim strConn
Dim pr As New ADODB.Parameter
Dim pr1 As New ADODB.Parameter
Dim pr2 As New ADODB.Parameter
strConn = "Provider = MSDAORA.1;User ID=satish;password=satish;Persist Security Info=False"
objConn.open strConn
With objComm
.CommandType = adCmdStoredProc
.CommandText = "get_user_name" 'procedure name
Set pr = .CreateParameter("user_id", adInteger, adParamInput)
pr.Value = 101
Set pr1 = .CreateParameter("fname", adVarChar, adParamOutput, 30)
Set pr2 = .CreateParameter("lname", adVarChar, adParamOutput, 30)
.Parameters.Append pr
.Parameters.Append pr1
.Parameters.Append pr2
.ActiveConnection = objConn
End With
Set objRec = New ADODB.Recordset
objComm.Execute
MsgBox "First name " & pr1 & " Last name " & pr2
End Sub
----------------------------------------------------------------------
|
|
|
|
|
|
|
|