private void btExport_Click(object sender, EventArgs e) { textBox1.Clear(); textBox1.Refresh(); this.Refresh(); try { using (MySqlConnection conn = new MySqlConnection(Program.ConnectionString)) { using (MySqlCommand cmd = new MySqlCommand()) { using (MySqlBackup mb = new MySqlBackup(cmd)) { cmd.Connection = conn; conn.Open(); textBox1.Text = mb.ExportToString(); conn.Close(); } } } MessageBox.Show("Export completed."); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void btExport_Click(object sender, EventArgs e) { try { string output = ""; using (MySqlConnection conn = new MySqlConnection(txtConnString.Text)) { MySqlCommand cmd = new MySqlCommand(); MySqlBackup mb = new MySqlBackup(cmd); cmd.Connection = conn; conn.Open(); output = mb.ExportToString(); } if (output.Length > (1024 * 100)) { lbError.Text = "The length of the output file has exceeded 100KB maximum length limit.<br />Try to use a smaller size of MySQL database sample."; lbError.Visible = true; } else { StoreFile.StoreSqlText(output); Server.Transfer("~/Result.aspx", true); } } catch (Exception ex) { lbError.Text = ex.Message; lbError.Visible = true; } }