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

How can I get around scope problems in a try/catch?

0 Answers  


What is console readkey ()?

0 Answers  


Is it possible to add two 50 digit numbers in .net? If yes what is the code snippet?

2 Answers   Cognizant, W3 Solutions, Zefer,


What are primitive data types in c#?

0 Answers  


Explain the three test cases in unit testing?

0 Answers   Siebel,






Explain constructor?

6 Answers   Wipro,


Differentiate between copy and default constructor.

0 Answers   TCS,


What is class and object c#?

0 Answers  


Which of the following API is used to hide a window?

0 Answers   3i Infotech,


What is serialization in c#?

0 Answers  


Explain dataset.acceptchanges method in .net?

0 Answers  


I have a very important query in my mind. Please help me regarding this. I don't have any real time exp in .net. But I have a knowledge it .net. I got an offer from an MNC company as a software developer has I had kept 2 years of fake exp. Even though for this job I had worked hard to crack interview for about an year. So, I would like to know how difficult it will be for working in real time as I don't have real time exp. Please tell me as soon as possible bcoz I need to join by next month. Can i sustain over there for a longer time or not. And also let me know how to work pressure will be over there. Please help me regarding this. I'm getting tension thinking about it. Thank you.

1 Answers  


Categories