private void Btn1_Click(object sender, EventArgs e) { string connetionString = null; //string sql = null; string name = ""; string pass = ""; connetionString = "Data Source=PD-JANAKAN;Initial Catalog=EnqInfo;Integrated Security=True"; using (SqlConnection con = new SqlConnection(connetionString)) { // // Open the SqlConnection. // con.Open(); // // The following code uses an SqlCommand based on the SqlConnection. // using (SqlCommand command = new SqlCommand("SELECT * FROM Login WHERE U_Name=@Usr", con)) { command.Parameters.AddWithValue("@Usr", UName.Text); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { name = reader.GetString(1); // Name string pass = reader.GetString(2); // Password string } if (name == UName.Text && pass == PWord.Text) { ClassEnq.Uname = UName.Text; MessageBox.Show("Password Accepted"); this.Close(); setEnableToolStripMenuItem(true); setEnableToolStripMenuItem1(true); setDisableToolStripMenuItem(false); } else { MessageBox.Show("Password Incorrect, Please Re-Enter Your Password"); setEnableToolStripMenuItem(false); setEnableToolStripMenuItem1(false); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)