关于登录的问题。
怎么把输入的用户名跟数据库中的用户名进行比较。
protected void Button1_Click(object sender, EventArgs e)
{
string yonghuming = this.TextBox1.Text.Trim();
string mima = this.TextBox2.Text.Trim();
string str = "select count(*) from denglu where yonghuming='" + yonghuming + "'and mima='" + mima + "'";
OleDbConnection con = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString());
OleDbCommand com = new OleDbCommand(str, con);
con.Open();
int ret = com.ExecuteNonQuery();
con.Close();
if (ret > 1)
{
Response.Redirect("~/首页.aspx");
}
else
{
Response.Write("<script>alert('用户帐号/密码错误。')</script>");
}
能不能帮我看看我这段代码有什么问题。为什么怎么调试他只有一种结果,就是用户帐号/密码错误。,是什么原因呢?求大神帮忙解答下。
{
string yonghuming = this.TextBox1.Text.Trim();
string mima = this.TextBox2.Text.Trim();
string str = "select count(*) from denglu where yonghuming='" + yonghuming + "'and mima='" + mima + "'";
OleDbConnection con = new OleDbConnection(System.Configuration.ConfigurationManager.AppSettings["SQLConnString"].ToString());
OleDbCommand com = new OleDbCommand(str, con);
con.Open();
int ret = com.ExecuteNonQuery();
con.Close();
if (ret > 1)
{
Response.Redirect("~/首页.aspx");
}
else
{
Response.Write("<script>alert('用户帐号/密码错误。')</script>");
}