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
%>