zoukankan      html  css  js  c++  java
  • .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;
            }

  • 相关阅读:
    浅谈聚类算法(K-means)
    多步法求解微分方程数值解
    本学期微分方程数值解课程总结(matlab代码)
    Stone Game
    Two Sum IV
    Insert into a Binary Search Tree
    Subtree of Another Tree
    Leaf-Similar Trees
    Diameter of Binary Tree
    Counting Bits
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/1271583.html
Copyright © 2011-2022 走看看