hi there ,
i have a simple login form using C#2008 And Sqlserver 2008 ,and it work very nice but the question is i need when the user Enter the password 3 time wrongly(if he forget or someone else try to enter his account) ,the account is blocked and in the same time the webcam take an image for the person in that computer and save it in sql table
i want to know can i do that!!! , if i can please give me the way to do it or simple code to add it in my login form
and this my login code :
1 private bool CompareStrings(string string1, string string2)
2 {
3 return String.Compare(string1, string2, true, System.Globalization.CultureInfo.InvariantCulture) == 0 ? true : false;
4 }
5
6 private void button1_Click(object sender, System.EventArgs e)
7 {
8 try
9 {
10 SqlConnection con = new SqlConnection();
11 con.ConnectionString = "Server=.\\SQLEXPRESS; Database=Sample; User Id=sa; password=sa123";
12 UGIcon.Open();
13
14 SqlCommand cmd = new SqlCommand("SELECT ISNULL(stUsername, '') AS stUsername, ISNULL(stPassword,'') AS stPassword, ISNULL(stRole,'') AS stRole FROM LoginDetails WHERE stUsername='" + textBoxUsername.Text + "' and stPassword='" + textBoxPassword.Text + "'", con);
15
16 SqlDataReader dr = cmd.ExecuteReader();
17
18 string userText = textBoxUsername.Text;
19 string passText = textBoxPassword.Text;
20 string stRole = "admin";
21
22 while (dr.Read())
23 {
24 if (this.CompareStrings(dr["stUsername"].ToString(), userText) &&
25 this.CompareStrings(dr["stPassword"].ToString(), passText) &&
26 this.CompareStrings(dr["stRole"].ToString(), stRole))
27 {
28 MessageBox.Show("OK");
29 }
30 else
31 {
32 MessageBox.Show("Error");
33 }
34
35 }
36
37 dr.Close();
38
39 con.Close();
40
41 }
42 catch(Exception ex)
43 {
44 MessageBox.Show(ex.Message);
45 }
46 }
thanx in advance