C# 调用存储过程
参考了很多文章,写了如下文字,算是分享吧
目的:更改积分,并作一定校验
一般的调试方法:
DECLAREEND;
更详细的调试方法还是PLSQL,选择要调试的过程名,找test,如果不能进入到里面去,好像要要编译,生成debug信息之类的。
END p_changevipbalance;
C#调用代码:
public static String CAL_changevipbalancebyStoredProcedure(string vipno, int point, string str_reason )
{//需要增加日志
string strCmd = OracleAccess.str_vip_update1 + point + OracleAccess.str_vip_update2 + vipno.Trim() + "\‘";
int old_points = 0; int after_point = 0; int kkk = 0; int myresult = 0;
//i = Convert.ToInt32(DBUtil.SqlExecuteScalar(strCmd.Replace("TESTA", OracleAccess.str_USER)));
if (exist_vip(vipno))
{
old_points = int.Parse(CAL_VipBalance(vipno));
OracleParameter[] parameters ={
new OracleParameter("vipno",OracleType.VarChar,50),
new OracleParameter("point",OracleType.VarChar,30),
new OracleParameter("str_reason",OracleType.VarChar,20),
new OracleParameter("myresult",OracleType.Int32)
};
parameters[0].Value = vipno; parameters[1].Value = point; parameters[2].Value = str_reason; parameters[3].Value = myresult; //parameters[13].Value = str_sku;// parameters[10].Value = str_no; parameters[11].Value = str_sku;
parameters[0].Direction = ParameterDirection.Input; parameters[1].Direction = ParameterDirection.Input; parameters[2].Direction = ParameterDirection.Input; parameters[3].Direction = ParameterDirection.Output;
try
{
YHJ_StoredProcedure.RunProcedure("WX_120719_FLXT.p_changevipbalance", parameters);
kkk = Convert.ToInt32(parameters[3].Value);
if (kkk>=1)
return OracleAccess.str_db_operate_sucess;
else
return "ERROR内部校验出错";
}
catch (Exception e)
{
throw e;
}
//DBUtil.SqlExecuteNonQuery(strCmd.Replace("TESTA", OracleAccess.str_USER)); //ok 防注入,不用
//after_point = int.Parse(CAL_VipBalance(vipno));
//if ((after_point - old_points) == point)
// return OracleAccess.str_db_operate_sucess;
//else
// return "ERROR内部校验出错";
}
else
return "ERROR会员不存在";
//return Convert.ToInt32(DBUtil.SqlExecuteScalar(strCmd.Replace("TESTA", OracleAccess.str_USER)));
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/handsome1234/article/details/46945091