예제 #1
0
        public static string ModifyPwd(string name, string oldpasswd, string newpasswd)
        {
            if (!m_SqlConnected)
            {
                return("修改失败");
            }

            string accout_name   = name;
            string old_EncPasswd = Md5Helper.MD5ToString(oldpasswd);
            string new_passwd    = newpasswd;
            string new_EncPasswd = Md5Helper.MD5ToString(newpasswd);

            string     ErrInfo = "";
            SqlCommand sqlComm = null;

            //*
            sqlComm = new SqlCommand("AC_sp_ModifyPassword", conn);
            //设置命令的类型为存储过程
            sqlComm.CommandType = CommandType.StoredProcedure;
            //设置参数
            sqlComm.Parameters.Add("@strGameAccount", SqlDbType.VarChar);
            sqlComm.Parameters.Add("@strOldEncryptGamePWD", SqlDbType.VarChar);
            sqlComm.Parameters.Add("@strNewGamePWD", SqlDbType.VarChar);
            sqlComm.Parameters.Add("@strNewEncryptGamePWD", SqlDbType.VarChar);
            //注意输出参数要设置大小,否则size默认为0,
            sqlComm.Parameters.Add("@strErrInfo", SqlDbType.VarChar, 512);
            //设置参数的类型为输出参数,默认情况下是输入,
            sqlComm.Parameters["@strErrInfo"].Direction = ParameterDirection.Output;
            //为参数赋值
            sqlComm.Parameters["@strGameAccount"].Value       = accout_name;
            sqlComm.Parameters["@strOldEncryptGamePWD"].Value = old_EncPasswd;
            sqlComm.Parameters["@strNewGamePWD"].Value        = new_passwd;
            sqlComm.Parameters["@strNewEncryptGamePWD"].Value = new_EncPasswd;
            //执行
            sqlComm.ExecuteNonQuery();
            //得到输出参数的值,把赋值给name,注意,这里得到的是object类型的,要进行相应的类型轮换
            ErrInfo = sqlComm.Parameters["@strErrInfo"].Value.ToString();

            return(ErrInfo);
        }
예제 #2
0
        public static string CreateAccount(string name, string passwd)
        {
            if (!m_SqlConnected)
                return "创建失败";

            mutex.WaitOne();
            string accout_name = name;
            string accout_password = passwd;
            string accout_password2 = Md5Helper.MD5ToString(passwd);


            string ErrInfo = "";
            SqlCommand sqlComm = null;
            //*
            sqlComm = new SqlCommand("AC_sp_CreateAccount", conn);
            //设置命令的类型为存储过程
            sqlComm.CommandType = CommandType.StoredProcedure;
            //设置参数
            sqlComm.Parameters.Add("@strGameAccount", SqlDbType.VarChar);
            sqlComm.Parameters.Add("@strGamePWD", SqlDbType.VarChar);
            sqlComm.Parameters.Add("@strEncryptGamePWD", SqlDbType.VarChar);
            //注意输出参数要设置大小,否则size默认为0,
            sqlComm.Parameters.Add("@strErrInfo", SqlDbType.VarChar, 512);
            //设置参数的类型为输出参数,默认情况下是输入,
            sqlComm.Parameters["@strErrInfo"].Direction = ParameterDirection.Output;
            //为参数赋值
            sqlComm.Parameters["@strGameAccount"].Value = accout_name;
            sqlComm.Parameters["@strGamePWD"].Value = accout_password;
            sqlComm.Parameters["@strEncryptGamePWD"].Value = accout_password2;
            //执行
            sqlComm.ExecuteNonQuery();
            //得到输出参数的值,把赋值给name,注意,这里得到的是object类型的,要进行相应的类型轮换
            ErrInfo = sqlComm.Parameters["@strErrInfo"].Value.ToString();
            mutex.ReleaseMutex();

            return ErrInfo;
        }