24号24秒

导航

 
/// <summary>
/// 执行数据库包体操作,返回结果
/// </summary>
/// <param name="cmdText">包体函数或存储过程</param>
/// <param name="commandParameters">参数集合</param>
/// <returns></returns>
public static int ExecuteNonQuery_package(string cmdText,string canshu)
{
int result;
OracleConnection conn = new OracleConnection(connstr);
OracleCommand cmd = conn.CreateCommand();
try
{
OracleParameter[] parameters = {
new OracleParameter("返回参数",OracleDbType.Int32,1,ParameterDirection.ReturnValue,true,0,0,"",DataRowVersion.Default,Convert.DBNull),
new OracleParameter("参数名与数据库一致",OracleDbType.Varchar2,100)
};
parameters[1].Value = canshu;
cmd.CommandText = cmdText;
cmd.CommandType = CommandType.StoredProcedure;
foreach (OracleParameter param in parameters) cmd.Parameters.Add(param);
conn.Open();
cmd.ExecuteNonQuery();
var aaa = parameters[0].Value.ToString();
result= Convert.ToInt32(aaa);
}
catch (Exception)
{

throw;
}
finally
{
cmd.Dispose();
conn.Close();
conn.Dispose();
}
return result;
}

 

posted on 2018-09-12 17:24  24号24秒  阅读(1500)  评论(0编辑  收藏  举报