c#做的管理系统出现的问题,帮忙解决下吧,我快纠结死了
private void button1_Click(object sender, EventArgs e)
         {
             if (this.textBox1.Text == "" || this.textBox2.Text == "")
             {
                 MessageBox.Show("用户名或密码不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.textBox1.Focus();
             }
             else
             {
                 string strcon = "Server=(local);Integrated Security=true;database=stu_info_manage";
                 try
                 {
                     SqlConnection conn = new SqlConnection(strcon);
                     conn.Open();
                     string str = "select * from user_info where user_name='" + this.textBox1.Text.Trim() + "'";
                     SqlCommand cmd = new SqlCommand(str, conn);
                     SqlDataReader read = cmd.ExecuteReader();
                     while (read.Read())
                     {
                         if (this.textBox2.Text.Trim() == read.GetString(1))
                         {
                             this.Hide();
                             Form3 newform3 = new Form3();
                             newform3.Show();
                         }
                         else
                         {
                             MessageBox.Show("密码错误!");
                         }
                     }
                     conn.Close();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
             }
         }
这是我做的登陆界面出现的问题。按照数据库里添加的user_name和user_psw输入。总显示密码错误。
------解决方案--------------------
我建议你 sql 语句这样
C# code
string str = "select count(*) from user_info where user_name='" + this.textBox1.Text.Trim() + "' and 密码列='" + this.textBox2.Text.Trim() + "'";