注册 登录
编程论坛 ASP.NET技术论坛

关于登录的问题。

chenjincheng 发布于 2013-03-25 11:06, 738 次点击
怎么把输入的用户名跟数据库中的用户名进行比较。
7 回复
#2
Aviva_Wang2013-03-25 13:04
select Name from table where Name =@Name
#3
awl8052013-03-25 13:41
你要注意数据库空格产生的影响。
#4
chenjincheng2013-03-25 14:31
   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>");

        }
能不能帮我看看我这段代码有什么问题。为什么怎么调试他只有一种结果,就是用户帐号/密码错误。,是什么原因呢?求大神帮忙解答下。
#5
Aviva_Wang2013-03-25 14:42
sql语句:
string  sql="select count(*) from denglu where yonghuming="+yonghuming+"and mima"+mima;
#6
chenjincheng2013-03-25 16:14
谢谢。
#7
Marchliheng2013-03-26 18:17
你好主人,你的sql语句写的真够棒尤其是最后一条语句。
#8
a6464049082013-03-28 22:01
连接字符串 !
这可以注入哦
1