ado.net执行oracle 存储过程如下:
OracleConnection con=new OracleConnection(strcon);
OracleCommand cmd=new OracleCommand();
OracleTransaction mytrans ;
try
{
con.Open ();
mytrans =con.BeginTransaction();
cmd.Connection =con;
cmd.CommandText ="rfgetid";
cmd.CommandType =CommandType .StoredProcedure;
cmd.Transaction =mytrans ;
OracleParameter parameter_in=new OracleParameter("as_bm",OracleType.Char);
OracleParameter parameter_out=new OracleParameter ("as_sxh",OracleType .Number );
parameter_in.Direction =ParameterDirection .Input;
parameter_out.Direction=ParameterDirection .Output ;
parameter_in .Value =tblname.ToUpper();
cmd.Parameters .Add(parameter_in );
cmd.Parameters.Add(parameter_out);
cmd.ExecuteNonQuery();
mytrans .Commit();
return int.Parse(parameter_out .Value.ToString()) ;
}
catch(Exception er)
{
throw new Exception(er.Message);
mytrans .Rollback();
}
finally
{
cmd.Dispose ();
con.Close ();
}
更多信息请查看IT技术专栏