sumithsumith
March 12th, 2007, 12:35 AM
Hi Friends,
I am very new to .net field.now i am working with c#.net 1.1 and sql server.
I want to check whether the user is genuine or not..he/she must be restricted to enter the wrong username/password for more than three times.how to do this???/\
I have written the code like this,to check for the correct username/password
***************************************
private void Button3_Click(object sender, System.EventArgs e)
{
SqlConnection con1=new SqlConnection("server=localhost;Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=sumith;Data Source=server0");
try
{
SqlCommand cmd1=new SqlCommand("select username,password from login",con1);
con1.Open();
SqlDataReader myreader = null;
myreader=cmd1.ExecuteReader();
while(myreader.Read())
{
if(TextBox4.Text == myreader["username"].ToString() && TextBox3.Text == myreader["password"].ToString())
{
Label6.Text="Login Successful";
}
if(TextBox4.Text != myreader["username"].ToString() || TextBox3.Text != myreader["password"].ToString())
{
Label6.Text="Login Failed";
}
}
}
}
catch(SqlException ex)
{
Label6.Text=ex.Message;
con1.Close();
}
}
}
******************************************************
How to interrupt the user from entering the wrong username/password for more than three times????
please help me with a piece of code
I am very new to .net field.now i am working with c#.net 1.1 and sql server.
I want to check whether the user is genuine or not..he/she must be restricted to enter the wrong username/password for more than three times.how to do this???/\
I have written the code like this,to check for the correct username/password
***************************************
private void Button3_Click(object sender, System.EventArgs e)
{
SqlConnection con1=new SqlConnection("server=localhost;Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=sumith;Data Source=server0");
try
{
SqlCommand cmd1=new SqlCommand("select username,password from login",con1);
con1.Open();
SqlDataReader myreader = null;
myreader=cmd1.ExecuteReader();
while(myreader.Read())
{
if(TextBox4.Text == myreader["username"].ToString() && TextBox3.Text == myreader["password"].ToString())
{
Label6.Text="Login Successful";
}
if(TextBox4.Text != myreader["username"].ToString() || TextBox3.Text != myreader["password"].ToString())
{
Label6.Text="Login Failed";
}
}
}
}
catch(SqlException ex)
{
Label6.Text=ex.Message;
con1.Close();
}
}
}
******************************************************
How to interrupt the user from entering the wrong username/password for more than three times????
please help me with a piece of code