private void bw_DoWork(object sender, DoWorkEventArgs e) { string file = txtCaminhoArquivo.Text; try { using (MySqlConnection conn = new MySqlConnection(constring)) { using (MySqlCommand cmd = new MySqlCommand()) { mb = new MySqlBackup(cmd); cmd.Connection = conn; conn.Open(); mb.ImportProgressChanged += new MySqlBackup.importProgressChange(mb_ImportProgressChange); mb.ImportFromFile(file); conn.Close(); mb.Dispose(); } } } catch (Exception err) { MetroMessageBox.Show(this, err.Message); } }
public void Dispose() { _connectionString = null; if (_mySqlBackup != null) { _mySqlBackup.Dispose(); } if (_mySqlCommand != null) { _mySqlCommand.Dispose(); } if (_mySqlConnection != null) { _mySqlConnection.Dispose(); } }