give suitable code for all login controls

Answer Posted / surojit

protected void Login1_Authenticate(object sender,
AuthenticateEventArgs e)
{ string u_id=Login1.UserName;
string pwd=Login1.Password;

SqlConnection con = new
SqlConnection("uid=sa;pwd=nivt;server=.;database=jobportal");
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select *
from rec_registration where rec_username='" + u_id + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);
if (Login1.UserName ==
ds.Tables[0].Rows[0][0].ToString() && Login1.Password ==
ds.Tables[0].Rows[0][1].ToString())
{
Session["rec_uid"] = u_id;
Session["rec_uname"] =
ds.Tables[0].Rows[0][3].ToString();
Session["rec_type"] =
ds.Tables[0].Rows[0][5].ToString();

Response.Redirect("rec_home.aspx");

}
else
{
Label2.Text = "Invalid Username/Password:";

}
}
catch(Exception ex)
{
Label3.Text = ex.Message.ToString();
Label2.Text = "Invalid Username";

}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
}

}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c# used for frontend or backend?

588


how to insert the data from the grid view to database table though button click.pls send the answer to mail id suri1319@gmail.com

1496


What is for loop in c#?

507


What is garbage collector and where should you use in .NET?

517


What is the usage of transponders?

551






Why do you need boxing in c#?

494


What do you mean by “finalize” and “finally” methods in c#?

488


How to find methods of a assembly file (not using ILDASM)?

647


Is xamarin free?

454


What is remote data?

469


What are the access modifiers in c#?

503


what is object-oriented programming (oop) language?

487


How do you declare an interface in c#?

488


Can we change static value in c#?

532


Explain about CTS?

553