C # calls Oracle stored procedure "reproduced"

Source: Internet
Author: User
Tags oracleconnection connectionstrings

Table numbervarchar2 (tenvarchar2 (4 numbervarchar2);   

2. Create a stored procedure with no parameters

CreateOr  replace procedureisbegin insert Span style= "color: #0000ff;" >into Test (id,name,sex,age)  (1, ' moses ' 

3. Write C # code to call this stored procedure with no parameters

 protected void button2_click (object sender, EventArgs e) {String OC = configurationmanager.connectionstrings[  "conn" ]. ToString (); OracleConnection conn = new OracleConnection (OC); Conn. Open (); OracleCommand orm = Conn. CreateCommand (); Orm. CommandType = CommandType.StoredProcedure; Orm. CommandText =  "proc1; Orm. ExecuteNonQuery (); Conn. Close (); } 

4. Write a stored procedure with parameters that do not have a return value

Replace proc2 (v_id number  varchar2)into test (id,name)values(v_id,v_name);  Commit;  End;  /

5.c# calls this stored procedure with no return value for the parameter

 Protectedvoid Button1_Click (Objectsender, EventArgs e) {if (String. IsNullOrEmpty (This. TextBox2.Text)) {This. TextBox2.Text ="The number cannot be empty";This. Textbox2.focus ();Return; }if (String. IsNullOrEmpty (This. TextBox3.Text)) {This. TextBox3.Text ="The name cannot be empty";This. Textbox3.focus ();Return; } String or=configurationmanager.connectionstrings["Conn"]. ToString (); OracleConnection OC =NewOracleConnection (or); Oc. Open (); OracleCommand om =Oc. CreateCommand (); Om.commandtype =CommandType.StoredProcedure; Om.commandtext ="Proc2"; Om. Parameters.Add ( "v_id" Oracletype.number). Direction = ParameterDirection.Input; om. Parameters[ "v_id"]. Value = this "v_name  ParameterDirection.Input; om. Parameters[ "v_name"] . Value = this 

6. Write a stored procedure with a parameter with a return value

Number)begincount (from test;  Commit;  End;  /

7.c# calls this stored procedure with a return value with a parameter

Protectedvoid Button1_Click (Objectsender, EventArgs e) {String or = configurationmanager.connectionstrings["Conn"]. ToString (); OracleConnection OC =new OracleConnection (or); OC. Open (); OracleCommand ocm = OC. CreateCommand (); ocm. CommandType = CommandType.StoredProcedure; ocm. CommandText =  "proc3; ocm. Parameters.Add ( "reccount  ParameterDirection.Output; ocm. ExecuteNonQuery (); this. TextBox1.Text = ocm. Parameters[ "reccount "". Value.tostring (); } 

C # calls Oracle stored procedure "reproduced"

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.