日期:2014-05-19  浏览次数:20799 次

请教c#+access 登录的问题
我编写的登录按钮代码如下:
protected   void   login_Click(object   sender,   EventArgs   e)
        {
                string   name   =   zygs_user.Text;
                string   pass   =   zygs_pwd.Text;
                try
                {
                       
                        OleDbConnection   objConn   =   new   OleDbConnection( "Provider=Microsoft.Jet.OleDb.4.0;Data   Source= "   +   Server.MapPath( "App_Data/zyq_user.mdb "));
                        objConn.Open();
                        string   str   =   "select   *   from   [zygs_user]   where   [user_ID]   = "   +   name   +   "   and   [user_pass]   = "   +   pass   +   " ";
                        OleDbCommand   Comm   =   new   OleDbCommand(str,   objConn);
                        OleDbDataReader   rd   =   Comm.ExecuteReader();
                        if   (rd.Read())
                        {
                                string   shuyu   =   rd[ "user_shuyu "].ToString();
                                Session[ "shuyu "]   =   shuyu;
                                Session[ "yonghu "]   =   name;
                                Response.Redirect( "~/login.aspx ");
                        }
                        else
                        {
                                zygs_user.Text   =   " ";
                                zygs_pwd.Text   =   " ";
                                Response.Write( " <script> alert(无法登录!) </script> ");
                                err.Text   =   "用户不存在! ";