asp.net调用oracle存储过程

cao4010578 2014-04-23 05:39:55
OracleParameter[] parms = {
new OracleParameter("U_ID",OracleType.Number,10)
};
parms[0].Value =U_ID;
int a = DbHelper.ExecuteNonQuery("vip_recharge", CommandType.StoredProcedure, parms);
return a > 0 ? true : false;
其中U_ID为70测试数据

报出PLS-00306: wrong number or types of arguments in call to 'VIP_RECHARGE'



public int ExecuteNonQuery(string commandText, CommandType commandType, OracleParameter[] parameters)
{
int count = 0;
using (OracleConnection connection = new OracleConnection(connectionString))
{
using (OracleCommand command = new OracleCommand(commandText, connection))
{
command.CommandType = commandType;//设置command的CommandType为指定的CommandType
//如果同时传入了参数,则添加这些参数
if (parameters != null)
{
foreach (OracleParameter parameter in parameters)
{
command.Parameters.Add(parameter);
}
}
connection.Open();//打开数据库连接
count = command.ExecuteNonQuery();
}
}
return count;//返回执行增删改操作之后,数据库中受影响的行数
}
...全文
87 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cao4010578 2014-04-24
  • 打赏
  • 举报
回复
这个是我调用 存储过程 create or replace procedure vip_recharge(in_uid in integer) is c_rd_id recharge_detail.rd_id%type; c_u_id recharge_detail.u_id%type; c_pay_time recharge_detail.pay_time%type; c_year_num recharge_detail.year_num%type; cursor vip_cursor is select rd_id,u_id,pay_time,year_num from recharge_detail where u_id=in_uid and pay_off='1' --是否付清 order by rd_id; begin open vip_cursor; loop fetch vip_cursor into c_rd_id,c_u_id,c_pay_time,c_year_num; --loop and fench exit when vip_cursor%notfound; merge into user_vip ma using (select b.u_id, nvl(a.u_id,0) aid, --用户名编号不存在设为0 case when c_pay_time>nvl(a.end_time,to_date('1970-01-01','yyyy-mm-dd')) then c_pay_time else a.begin_time --支付时间大于结束时间(结束时间为null时即为1970-01-01)则为支付时间否则为结束时间作为vip的开始时间 end vip_begin_time, case when sysdate>nvl(a.end_time,to_date('1970-01-01','yyyy-mm-dd')) then add_months(sysdate, 12*c_year_num) else add_months(a.end_time, 12*c_year_num) --系统当前时间大于结束时间(结束时间为null时即为1970-01-01)则系统当前时间添加年限(12*c_year_num),否则结束时间添加年限作为vip结束时间 end vip_end_time, b.year_statis from user_vip a right join (select u_id,sum(year_num) year_statis from recharge_detail where u_id=c_u_id and pay_off>0 --pay_off 0 1 2 group by u_id)b on a.u_id=b.u_id) mb on (ma.u_id=mb.u_id and ma.u_id=mb.aid) --用户会员表中的用户编号和recharge_detail信息变更表中的信息相同时匹配 when matched then update set ma.begin_time=mb.vip_begin_time, ma.end_time=mb.vip_end_time, ma.year_statis=mb.year_statis --设置 when not matched then insert (u_id,begin_time,end_time,year_statis) values(c_u_id,sysdate,add_months(sysdate,12*c_year_num),c_year_num); --添加 update recharge_detail set pay_off=2 where rd_id=c_rd_id; --修改 commit; end loop; close vip_cursor; end vip_recharge; --通过用户id
EdsionWang 2014-04-23
  • 打赏
  • 举报
回复
这错误提示不是很清楚了吗?传的参数出问题啦,检查一下跟存储过程里面的参数个数,数据类型是否一致
笨笨的小菜 2014-04-23
  • 打赏
  • 举报
回复
输入的参数个数或类型与你数据库中的存储过程要求的参数个数或类型不一 致,要看下你具体的存储过程才能确定。

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧