C # call Oracle stored procedure

xiaoxiao2021-03-06  58

Oracle 1. Create an Oracle stored procedure create or replace procedure proce_test (paramin in varchar2, paramout out varchar2, paraminout in 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);

Test Result: DDFF C # aspect 1. Create an interface

Type object name text attribute 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) Reference Oracle's components add using system.data.data.Data.OracleClient; (2) Double-click the "Call" button on the interface to prepare 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"; // Store process name

cmd.commandtype = commandType.StoredProcedure; // Declaring the parameters of the stored procedure // stored procedure, parameter represents parameter name, oracletype.varchar represents parameter type, 20 represents the size of the parameter OracleParameter param_in = cmd.parameters.add ("paramin" , Oracletype.varchar, 20);

PARAM_IN.DIRECTION = parameterDirection.input; // Represents parameters storage method

PARAM_IN.VALUE = m_txti.text;

OracleParameter Param_out = cmd.Parameters.add ("paramout", ORACLETY.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 (); // Perform a stored procedure

cmd.executenonQuery (); // Returns the value of the parameter

m_print.text = "Display:" param_out.value.toTOString ();

CONN.CLOSE ();

}

转载请注明原文地址:https://www.9cbs.com/read-114082.html

New Post(0)