asp教程.net c#调用mssql存储过程方法
按道理来讲只要是程序与sql打交道的程序都可以调用mssql存储过程的,下面我们提供了二种asp.net教程 c#调用mssql存储过程方法
*/
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.executenonquery();
textbox1.text = com.parameters["v_sal"].value.tostring();
con.close();
}
/*
存储过程创建代码
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('员工号:'||v_empno||' 工资:'||v_sal);
end;
*/
//调用方法二
direction = parameterdirection.input;
para.value = 名字;
sqlparameter para2 = new sqlparameter("@pwd",sqldbtype.char,10);
para.direction = parameterdirection.input;
para.value = 密码;
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; //返回值
%>
|