注册 登录
编程论坛 VC.NET论坛

一个很简单的登陆代码,大家帮我看一下哪里不对了。谢谢

风中的承诺 发布于 2008-09-25 21:39, 2623 次点击
SqlConnection newConn = new SqlConnection(@"Data Source=www-08a954c4a44\sqlexpress;Initial Catalog=library;Integrated Security=True");
            newConn.Open();
这是对的
            SqlCommand thisCommand = new SqlCommand("select count(*) from User where ManagerID=" + this.textBox1.Text + " and ManagerPassword=" + this.textBox2.Text, newConn);

            SqlDataReader thisReader = thisCommand.ExecuteReader();
这里运行不通过

            if (thisReader.Read())是不是这样判断有没有返回值?
            {
                this.Visible = false;
                Form mainForm = new Form1(this.textBox1.Text, "tech");
                mainForm.ShowDialog();
                this.Close();
            }
1 回复
#2
海子星竹2008-09-29 23:56
SqlCommand thisCommand = new SqlCommand("select count(*) from User where ManagerID='" + this.textBox1.Text + "' and ManagerPassword='" + this.textBox2.Text, newConn)+"'";
1