try
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=ARUSHRAJ-PC;Initial Catalog=sample;User ID=sa;Password=niit";
con.Open();
SqlCommand cmd = new SqlCommand("Select * From Login_Details Where UserType=@ut AND UserName=@nm AND Password = @ps", con);
cmd.Parameters.Add("@ut", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@nm", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@ps", SqlDbType.VarChar, 50);
cmd.Parameters["@ut"].Value = comboBox1.Text;
cmd.Parameters["@nm"].Value = textBox1.Text;
cmd.Parameters["@ps"].Value = textBox2.Text;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
DialogResult rd = MessageBox.Show("Login Succesfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (rd == DialogResult.OK)
{
if (dr.Read())
{
label6.Text = dr[1].ToString();
label8.Text = dr[0].ToString();
}
}
}
else
{
ctr = ctr + 1;
if (ctr < 3)
{
DialogResult dr1 = MessageBox.Show("You have enter wrong Username or Password. If you are forget your Password or UserName ", "Warning", MessageBoxButtons.RetryCancel,MessageBoxIcon.Warning);
if (dr1 == DialogResult.Cancel)
{
Application.Exit();
}
linkLabel6.Show();
textBox1.Text = "";
textBox2.Text = "";
textBox1.Focus();
}
else
{
MessageBox.Show("You can not access this appliction.Because of you enter 3 times wrong Username or Password", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
textBox1.Text = "";
textBox2.Text = "";
Application.Exit();
}
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Login_Form
4404
18-Jul-2011
James Smith
18-Jul-2011Please remember few points while writing blog, so that user are able to read and understand it properly. Here I am giving you few tips.
1) Give an introduction about your blogs such as what is purpose of it and how can you perform some task.
2) Explain some terms related with your blogs.
Here I am providing you few links of blog so that you can have an idea about writing.
https://www.mindstick.com/blog/181/lambda-expression-in-c-sharp
https://www.mindstick.com/blog/186/sending-mail-in-asp-dot-net
https://www.mindstick.com/blog/189/creating-dll-in-c-sharp
Anonymous User
18-Jul-2011First of all I'd like to appreciate you for writing this blog and spreading your knowledge, but this is not the right format of writing blog. If you really want to share your knowledge then do it in a proper manner.
From your current blog no one will understand anything. Try to explain your blog and if you have used any code then try to explain the code as much as possible. For example check out other Blogs on this site.
Keep writing and try to improve your blog quality.
Thanks.
Arush Raj
18-Jul-2011Uttam Misra
18-Jul-2011Good Luck!
Arush Raj
18-Jul-2011