asp.net调用Oracle存储过程,获取返回值!(例子)

12 篇文章 0 订阅
OracleConnection conn = new OracleConnection(SQLHelper.GetConnectionString());//SQLHelper.GetConnectionString()——连接字符串
OracleCommand cmd = new OracleCommand("pkg_car_state.proc_upd_car_model_state", conn);//创建command对象
cmd.CommandType = CommandType.StoredProcedure;//设置CommandType类型

//设置参数
OracleParameter[] prams = { new OracleParameter("p_old_car_model_id", OracleType.Int16),
                      new OracleParameter("p_new_car_model_id", OracleType.Int32),
                      new OracleParameter("p_tk_store_id", OracleType.Int32),
                      new OracleParameter("p_bk_store_id", OracleType.Int32),
                      new OracleParameter("p_begin_date", OracleType.DateTime),
                      new OracleParameter("p_end_date", OracleType.DateTime),
                      new OracleParameter("p_cur_use_no", OracleType.VarChar,50),
                      new OracleParameter("p_use_mode", OracleType.VarChar,50),
                      new OracleParameter("p_user_id", OracleType.Int32),
                      new OracleParameter("p_rst_code", OracleType.VarChar,50),
                      new OracleParameter("p_rst_msg", OracleType.VarChar,50)};

prams[0].Direction = ParameterDirection.Input;
prams[1].Direction = ParameterDirection.Input;
prams[2].Direction = ParameterDirection.Input;
prams[3].Direction = ParameterDirection.Input;
prams[4].Direction = ParameterDirection.Input;
prams[5].Direction = ParameterDirection.Input;
prams[6].Direction = ParameterDirection.Input;
prams[7].Direction = ParameterDirection.Input;
prams[8].Direction = ParameterDirection.Input;
prams[9].Direction = ParameterDirection.Output;
prams[10].Direction = ParameterDirection.Output;

//参数赋值
prams[0].Value = 0;
prams[1].Value = order.CarModelID;
prams[2].Value = order.TakeBelongStoreId;
prams[3].Value = order.BackBelongStoreId;
prams[4].Value = order.TakeCarDate;
prams[5].Value = order.BackCarDate;

prams[6].Value = boNo;
prams[7].Value = "租赁";
prams[8].Value = 134;
           
for (int i = 0; i < prams.Length; i++)
{
    cmd.Parameters.Add(prams[i]);
}

OracleDataAdapter caChe = new OracleDataAdapter(cmd);
DataTable datatable = new DataTable();
caChe.Fill(datatable);

//获取返回值
string tempStr = prams[9].Value.ToString();//返回代码;0表示成功,非0表示不成功
string reMsg = prams[10].Value.ToString();//返回提示信息

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值