He need some help with authentication

Im trying to design a login form that will check against a SQL database to see if the username and password are correct.

Could some one please supply some sample code of how i would do this.

Thanks, Greg



Answer this question

He need some help with authentication

  • wx

    Are you working on ASP.net 2.0, check the following link

    http://www.asp.net/QuickStart/aspnet/doc/ctrlref/login/default.aspx


  • Golgot13

    Hi.

    You can use FormAuthintication class. Below I am including a psude code. Please try

    SqlConnection con = new SqlConnection("connection string");

    SqlCommand commnd = new SqlCommand("Select UserName, Password From User Where UserName='Bappi' AND Password='Bappi'");

    commnd.CommandType = CommandType.Text;

    con.Open();

    SqlDataReader reader = commnd.ExecuteReader(CommandBehavior.CloseConnection);

    if (reader.Read())

    {

    FormsAuthentication.RedirectFromLoginPage("page url", true);

    }

    else

    {

    label1.Text = "Invalid Credential";

    }

    Try this code.

    regards

    bp



  • He need some help with authentication