zoukankan      html  css  js  c++  java
  • 登陆代码

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.OleDb;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            bool Authenticated = false;
            Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);
            e.Authenticated = Authenticated;
            if (Authenticated == true)
            {
                Response.Redirect("1.aspx");
            }
        }

        private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
        {

            bool boolReturnValue = false;
            OleDbConnection conn = new OleDbConnection("provider=Microsoft.jet.oledb.4.0;data source=|datadirectory|pa.mdb ");
            //OleDbConnection conn = new OleDbConnection("provider=Microsoft.jet.oledb.4.0;data source=" + Server.MapPath("pa.mdb") + "");
            conn.Open();
            OleDbCommand comm = new OleDbCommand("select * from pa", conn);
            using (OleDbDataReader dr = comm.ExecuteReader(CommandBehavior.CloseConnection))
            {
                while (dr.Read())
                {
                    if ((UserName == dr["username"].ToString()) & (Password == dr["password"].ToString()))
                    {
                        boolReturnValue = true;
                    }
                }
                dr.Dispose();
            }
            return boolReturnValue;

        }
    }

    天道酬勤,厚积薄发。 君子之行,静以修身,俭以养德。 非淡泊无以明志,非宁静无以致远。 如有恒,何须三更起,半夜眠;最怕莫,三天打鱼两天晒网,竹篮打水一场空。
  • 相关阅读:
    C++笔记--模板
    C++笔记--抽象机制
    C++--VECTOR的简单应用
    C++面试笔记--STL模板与容器
    C++面试笔记--指针和引用
    《转载》什么变量在堆内存里存放,什么变量在栈内存里存放
    C++面试笔记--const、sizeof
    C++面试笔记--宏定义
    C++笔记--指针数组和结构
    C++笔记--异常
  • 原文地址:https://www.cnblogs.com/houweidong/p/3366556.html
Copyright © 2011-2022 走看看