日期:2014-05-17  浏览次数:20776 次

C#又求大神。。急。。新手
 String password = this.textBox1.Text;
            String password1 = this.textBox2.Text;
            String password2 = this.textBox3.Text;
            if (!password1.Equals(password2))
            {
                MessageBox.Show ("两次密码输入不一致");
                return;
            }
            String cnno = "Data Source=HP-PC;Initial Catalog=FIRST;Integrated Security=True;Pooling=False";
            SqlConnection connection = new SqlConnection(cnno);
            string sql = string.Format("update Logind set Upw='{2}' where Uname='{0}'and Upw='{1}'", send_str, password, password1);
            connection.Open();
            SqlCommand command = new SqlCommand(sql, connection);
            int num = Convert.ToInt32(command.ExecuteScalar());

            try
            {
                if (num > 0)
                {

                    MessageBox.Show("修改成功!");
                }
                else
                {
                    MessageBox.Show("原密码错误!");
                }


            }
            catch (Exception ex)
            {

                MessageBox.Show("错误异常" + ex);
            }
            finally
            {
                connection.Close();
            }这是我编写的修改密码的代码,可是不管我原密码输什么都可以修改怎么回事呢。。求指导
------最佳解决方案--------------------<