用户登录简单后台代码

作者:互联网   出处:控件中国网   2014-11-05 19:05:19   阅读:1

用户登录简单后台代码

     int userflag;
            string strconn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\BlogSystem.mdb;Persist Security Info=True";
            string strcmd = " SELECT * FROM USER_INFO WHERE USER_NAME = '" + txtusername.Text.Trim() + "' AND USERPWD = '" + txtuserpasswd.Text.Trim() + "'";
            OleDbConnection conn = new OleDbConnection(strconn);
            OleDbCommand cmd = new OleDbCommand(strcmd, conn);
            conn.Open();
            userflag = Convert .ToInt32( cmd.ExecuteScalar());
            if (userflag > 0)
            {

                Response.Write("<script>alert(\"登陆成功!\")</script>");
                Session["userid"] = txtusername.Text;
                Server.Transfer("Default.aspx");
            }
            else
            {
                Response.Write("<script>alert(\"密码错误,登录失败!\")</script>");

            }
            conn.Close();

 

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat