• .net调用存储过程时的输出函数


    两年以前,我曾经因为输出的参数取不全而不用这个 Output了,今天我才知道bug所在,我没有指定Output的大小 ,如代码红字(ExecuteSqlCommandSql就是个执行存储过程的方法,这不写了)   

    另外,如果定义parameters[3].Direction = ParameterDirection.InputOutput;的话,如果不指定大小,那么你输入多长,那么返回字符串的长度就是多长

    public String ChangePassword(String OrginUserId, String Password, String NewPassword)
            {
                SqlParameter[] parameters = {
                    new SqlParameter("@OrginUserId",OrginUserId),
                    new SqlParameter("@Password",Password),
                    new SqlParameter("@NewPassword",NewPassword),
                    new SqlParameter("@ErrorMessage", SqlDbType.NVarChar,15)
                };
                parameters[3].Direction = ParameterDirection.Output;
                SQLHelper MySQLHelper = new SQLHelper();
                String ReturnStr;
                try
                {
                    MySQLHelper.ExecuteSqlCommandSql(_ChangePassword, parameters);
                    ReturnStr = parameters[3].Value.ToString();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                return ReturnStr;
            }

  • 相关阅读:
    Linux下的压缩zip,解压缩unzip命令具体解释及实例
    编程验证哥德巴赫猜想
    HDU 4735 Little Wish~ lyrical step~(DLX , 反复覆盖)
    The 2013 South America/Brazil Regional Contest 题解
    【 D3.js 高级系列 — 2.0 】 捆图
    怎么让百度收录站点的图片呢?
    ios-UI1
    oc85--利用宏定义简化单例
    oc84--单利
    oc83--自定义类实现copy方法
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/1271583.html
Copyright © 2020-2023  润新知