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

Contrast between an interface and abstract class?

749


What do you know about device context?

726


Is functional interface runnable?

678


What is msil, and why should developers need an appreciation of it if at all?

818


What is a hashset c#?

654


What is class sortedlist underneath?

746


What does console mean c#?

692


Is string a class in c#?

652


What is an object and a class?

769


Can we have multiple threads in one app domain?

726


Why objects are stored in heap in c#?

680


What exactly happens when we debug and build the program?

2183


What is part of a method signature in c#?

670


What is a void c#?

674


Is and as in c#?

670