give suitable code for all login controls



give suitable code for all login controls..

Answer / 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

More C Sharp Interview Questions

Why do you need boxing in c#?

0 Answers  


What is singleordefault c#?

0 Answers  


How to put assembly in gac?

0 Answers  


What is the Difference between directcast and ctype?

1 Answers   Wipro,


How do you pass reference parameters in c#?

0 Answers  






What are the Types of caching

0 Answers   TCS,


What sort algorithm does c# use?

0 Answers  


Why do canadians say zed?

0 Answers  


What is Lambda Expression?

1 Answers  


I created a class which is inherited from interface IDisposable. Now if I use object of this class with using keyword. Then How the dispose method will get call. Does garbage collector call it or some else.

2 Answers   Sapient,


Can we have 2 main methods in c#?

0 Answers  


What is the difference between webgarden and webfarm?

1 Answers   Mphasis,


Categories