protected override void Dispose(bool disposing) { lock (this) { if (!_disposed) { try { // Release any unmanaged resources // Release any managed resources if (disposing) { if (_shouldDisposeSelectCommand) { if (SelectCommand != null) { SelectCommand.Dispose(); SelectCommand = null; } } } } finally { _disposed = true; base.Dispose(disposing); } } } }
public void Dispose() { SelectCommand.Dispose(); UpdateCommand.Dispose(); InsertCommand.Dispose(); DeleteCommand.Dispose(); }
/////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Cleans up resources (native and managed) associated with the current instance. /// </summary> /// <param name="disposing"> /// Zero when being disposed via garbage collection; otherwise, non-zero. /// </param> protected override void Dispose(bool disposing) { try { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// if (disposeSelect && (SelectCommand != null)) { SelectCommand.Dispose(); SelectCommand = null; } if (InsertCommand != null) { InsertCommand.Dispose(); InsertCommand = null; } if (UpdateCommand != null) { UpdateCommand.Dispose(); UpdateCommand = null; } if (DeleteCommand != null) { DeleteCommand.Dispose(); DeleteCommand = null; } } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// } } finally { base.Dispose(disposing); // // NOTE: Everything should be fully disposed at this point. // disposed = true; } }
/////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { try { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// if (SelectCommand != null) { SelectCommand.Dispose(); SelectCommand = null; } if (InsertCommand != null) { InsertCommand.Dispose(); InsertCommand = null; } if (UpdateCommand != null) { UpdateCommand.Dispose(); UpdateCommand = null; } if (DeleteCommand != null) { DeleteCommand.Dispose(); DeleteCommand = null; } } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } finally { base.Dispose(disposing); } }
protected override void Dispose(bool disposing) { if (disposing) { if (!_disposed) { _disposed = true; if (_shouldDisposeSelectCommand) { if (SelectCommand != null) { SelectCommand.Dispose(); SelectCommand = null; } } base.Dispose(disposing); } } }
private void Button1_Click(object sender, EventArgs e) { try { string myConnection = "datasource=localhost;port=3306;username=root;password=EM@#!!e8e86six"; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand SelectCommand = new MySqlCommand("select * from software_proj.admin_table where Admin_ID ='" + this.username_txt.Text + "' and Password='******';", myConn); MySqlDataReader myReader; myConn.Open(); myReader = SelectCommand.ExecuteReader(); int count = 0; while (myReader.Read()) { count = count = 1; } if (count == 1) { //MessageBox.Show("Username and Password is correct"); this.Hide(); Student addS = new Student(); addS.ShowDialog(); } else { try { myReader.Close(); SelectCommand = new MySqlCommand("select * from software_proj.students_table where Student_ID ='" + username_txt.Text + "' and Password='******';", myConn); MySqlDataReader myReader2; myReader2 = SelectCommand.ExecuteReader(); while (myReader2.Read()) { count = count = 1; } if (count == 1) { //MessageBox.Show("Username and Password is correct"); string getID = myReader2.GetInt32("Student_ID").ToString(); // Store the student_ID into getID to pass it to student_cousres_display window form this.Hide(); student_courses_display student_courses_display = new student_courses_display(getID); student_courses_display.ShowDialog(); } else { MessageBox.Show("Username and Password is not correct...Please Try Again!!!"); } } catch (Exception ex) { _ = MessageBox.Show(ex.Message); } } myConn.Close(); SelectCommand.Dispose(); } catch (Exception ex) { _ = MessageBox.Show(ex.Message); } }