Asp.net C # Call the mssql stored procedure method

Source: Internet
Author: User
Tags mssql oracleconnection

Asp tutorial. net c # Call the mssql stored procedure method
In principle, as long as the program is dealing with SQL, it can call the mssql stored procedure. Below we provide two asp.net tutorial c # Call the mssql stored procedure method
*/

String constr = "data source = test; user id = scott; password = tiger ";
Oracleconnection con = new oracleconnection (constr );
Oraclecommand com = new oraclecommand ("sp2", con );
Com. commandtype = commandtype. storedprocedure;
Con. open ();
Oracleparameter p1 = new oracleparameter ("v_empno", oracletype. int32 );
Oracleparameter p2 = new oracleparameter ("v_sal", oracletype. double );
P1.direction = parameterdirection. input;
P1.value = 7369;
P2.direction = parameterdirection. output;
Com. parameters. add (p1 );
Com. parameters. add (p2 );
Com.exe cutenonquery ();
Textbox1.text = com. parameters ["v_sal"]. value. tostring ();
Con. close ();
  }
 
/*
Stored procedure creation code
 
Create or replace procedure sp2 (v_empno number) is
V_sal number (7,2 );
Begin
Update emp set sal = sal + 200 where empno = v_empno;
Select sal into v_sal from emp where empno = v_empno;
Dbms_output.put_line ('employee ID: '| v_empno | 'salary:' | v_sal );
End;

*/
 
// Call method 2
 

Direction = parameterdirection. input;
Para. value = name;
Sqlparameter para2 = new sqlparameter ("@ pwd", sqldbtype. char, 10 );
Para. direction = parameterdirection. input;
Para. value = password;
Sqlparameter para = new sqlparameter ("@ isvalid", sqldbtype. char, 10 );
Para. direction = parameterdirection. returnvalue;
Sqlcommand mycommand = new sqlcommand ("checkpass", conn)
Mycommand. commandtype = commandtype. storedprocedure;
Mycommand. parameters. add (para );
Mycommand. parameters. add (para2 );
Mycommand. excutenonquery ();
Bool isvalid = mycommand. parameters ["@ isvalid"]. value; // return value
%>
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.