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