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

What do you mean by streamreader/streamwriter class in c#?

739


What is the difference between method overriding and method overloading?

692


Can mvc be used for desktop applications?

733


How does array sort work?

703


What is the difference between and xml documentation tag?

783


What is list array in c#?

669


How can we set class to be inherited, but prevent the method from being over-ridden?

800


What is binary search tree in data structure?

700


What is data quality assurance?

668


Can we inherit static class in c#?

721


What are the different types of delegates?

717


Why do we need private constructor in c#?

685


What is the difference between an implicit conversion and an explicit conversion?

727


What is difference between ienumerable and ienumerator in c#?

738


What is response redirect in c#?

688