Everybody share C # calling Oracle stored Procedures

Source: Internet
Author: User
Tags interface
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 ();





}





?











Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.