qq_38892945
qq_38892945
2017-05-23 05:39
采纳率: 78.6%
浏览 1.8k

asp.net设计登录界面与access数据库连接

用asp.net编写了一个成绩查询的登录界面,用了sqldatasource控件连接了access中的一个成绩管理信息.accdb数据库,怎么来编写

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • a314066646
    FEN_TA 2017-05-23 07:13
    已采纳

    见用户表。大致内容id,username,password;
    登录界面放两个字段username,password
    请求后台根据提交的字段查询数据库用户表是否存在用户

    点赞 评论
  • qq_38892945
    qq_38892945 2017-05-23 06:13

    求大神帮忙啊,目前在登录按钮不知道怎么写代码了

    点赞 评论
  • kalizccm
    kalizccm 2021-07-21 10:20

    给你一段我的后端代码参考一下把

    string user = context.Request["InputUsername"];
                string password = context.Request["InputPassword"];
                if (SafeCheck(user) == false || SafeCheck(password) == false)
                {
                    context.Response.Write("服务器拒绝处理不安全字符串");
                    return;
                }
                string databasepath = HttpContext.Current.Server.MapPath("../DataBase/users.mdb");
                OleDbConnection objConn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source="+ databasepath);
                objConn.Open();
                string str = "select * from users where username = '" + user + "'and password='" + password + "'";
                OleDbCommand Comm = new OleDbCommand(str, objConn);
                OleDbDataReader rd = Comm.ExecuteReader();
                if (rd.Read())
                {
                    context.Response.Write("欢迎," + user);
                    HttpCookie objCookie = new HttpCookie("LoginCookie");
                    objCookie.Expires = DateTime.Now.AddDays(1);
                    objCookie.Values["Username"] = user;
                    objCookie.Values["Label"] = rd.GetString(rd.GetOrdinal("Label"));
                    objCookie.Values["Right"] = rd.GetString(rd.GetOrdinal("Right"));
                    context.Response.Cookies.Add(objCookie);
                }
    
    
    点赞 评论

相关推荐