我做了个图书管理系统的登录系统,需要连接sqlserver那种,但是进入系统后修改密码时总是出错,希望高手给出修改密码的代码!谢谢!!

解决方案 »

  1.   

    你要修改哪些密码呢?把你出错的代码发出来帮你改才可以的啊,修改密码就是执行一条sql语句而已了,发来帮你改一下
      

  2.   

    贴代码看看啊~~~~UPDATE 表 SET 密码字段 = '新密码' WHERE 登录名字段 = '登录名'
      

  3.   


    主要就是 sql数据库操作更新的问题LZ 自己在去试试看。。
      

  4.   


    string sql = "update 登陆表 set 原密码='"
                    + 【这里写新密码】+ "'  where 登陆名 ='" + 【这里写刚才登陆的登录名】+ "' ";try
                {
                    //执行添加操作
                    int n = new DataBase().runUpdate(sql);
                    if (n > 0)
                    {
                        MessageBox.Show("系部信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("系部信息修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch { }********************************************上面调用了一个方法  runUpdate()代码如下
    public static String sconn = ***********************;//这里写你的连接串
            SqlConnection conn;
    //打开连接
            public bool open()
            {
                //if (this.conn == null)
                    
                try
                {
                    this.conn = new SqlConnection(sconn);
                    conn.Open();
                    return true;
                }
                catch
                {
                    return false;
                }        }
            //关闭连接
            private   void close()
            {
                if (this.conn != null)
                {
                    this.conn.Close();
                }
            }//执行更新操作
            public   int runUpdate(String sql)
            {
                int n = -1;
                if (this.open() == false)
                {
                    throw new Exception("打开连接失败,操作结束!");
                }
                SqlCommand cmd = new SqlCommand(sql, this.conn);            try
                {
                    n = cmd.ExecuteNonQuery();
                }
                catch 
                {
                    //throw new Exception("执行更新失败,消息:" + err.Message);
                    return n;
                }
                this.close();
                return n;
            }
    接分..............
      

  5.   

    UPDATE TABLENAME SET 密码字段 = '新密码' WHERE 登录名字段 = '登录名'
      

  6.   

    修改密码成功并且正确的话。
    首先,你是登陆用户,自然先要获取到你的登陆名称或者ID<例如:userid是登陆账号:110 userPWd 密码:110,user 表>
    update user set userPWd="123" where userid ="110"