private void btnLogin_Click(object sender, EventArgs e) { try { //Connecting Database form SqlDbConnect.cs Class con = new SqlDbConnection(); con.SqlQuery("select * from LookDB.dbo.Users where UserName='" + this.username_txt.Text + "' and Password='" + this.password_txt.Text + "' ;"); SqlDataReader Reader; Reader = con.cmd.ExecuteReader(); int count = 0; while (Reader.Read()) { count = count + 1; } if (count == 1) { MessageBox.Show("Successfully Login. Press OK to Continue", "Login Successful", MessageBoxButtons.OK, MessageBoxIcon.None); this.Hide(); MainWindow newForm = new MainWindow(); newForm.ShowDialog(); } else if (count > 1) { MessageBox.Show("Access Denied!"); } else MessageBox.Show("Your username or password is incorrect. Please try again.", "Warning", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)