oracle| stored procedures Everybody share C # calling Oracle stored Procedures
Execution Results
??????
?
??????
?
?????
?
Oracle Aspect
1. Create Oracle Process Storage
Create or Replace procedure Proce_test (paramin in Varchar2,paramout out varchar2,paraminout into out varchar2)
as
? Varparam VARCHAR2 (28);
begin
? Varparam:=paramin;
? paramout:=varparam| | Paraminout;?
end;
2. Test process Storage
Declare
? Param_out VARCHAR2 (28);
? Param_inout VARCHAR2 (28);
begin
? param_inout:= ' FF ';??
? Proce_test (' DD ', param_out,param_inout);??
? Dbms_output.put_line (param_out);
end;
?
test results: DDFF
C # Aspects
1. Create an interface
?
type
Object Name
Text Property value
Button
Button1
Call
Label
Label1
A:
Label
Label2
B:
Label
M_input
input
Label
M_input_output
InputOutput
Label
M_print
Display:
TextBox
M_txti
?
TextBox
M_txtio
?
?
2. Display Code
?
(1) refers to Oracle's component
??? Add a using System.Data.OracleClient to your code;
(2) in the interface double-click the "Call" button, write the following code:
private void Button1_Click (object sender, System.EventArgs e)
???????? {
????????????? String mconn= "Data source=ora9i.ora.com;user id= ora;password= ora";//Connection Database
????????????? Conn=new OracleConnection (Mconn);
????????????? Cmd=conn. CreateCommand ();
????????????? cmd.commandtext= "proce_test";//stored Procedure name
????????????? cmd.commandtype=commandtype.storedprocedure;//declares that a stored procedure is invoked
????????????? The parameters of the stored procedure, paramin represents the parameter name, Oracletype.varchar represents the parameter type, and 20 represents the size of the parameter
????????????? OracleParameter Param_in=cmd. Parameters.Add ("Paramin", oracletype.varchar,20);
????????????? Param_in. direction=parameterdirection.input;//represents the way in which parameters are stored
????????????? Param_in. Value=m_txti.text;
OracleParameter Param_out=cmd. Parameters.Add ("Paramout", oracletype.varchar,20);
????????????? Param_out. Direction=parameterdirection.output;
OracleParameter Param_inout=cmd. Parameters.Add ("Paraminout", oracletype.varchar,20);
????????????? Param_inout. Direction=parameterdirection.inputoutput;
????????????? Param_inout. Value=m_txtio.text;
????????????? Conn. Open ();
????????????? Execute stored Procedure
????????????? Cmd. ExecuteNonQuery ();
????????????? Returns the value of a parameter
????????????? M_print.text= "Show:" +param_out. Value.tostring ();
????????????? Conn. Close ();
}
?