I am building a button to back up my db
via C#
application,
is running fine, however at the time of applying ExecuteNonQuery is accusing% error of%.
Follows:
Designate Path:
private void Browser_Click(object sender, EventArgs e)
{
FolderBrowserDialog dlg = new FolderBrowserDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
textBox1.Text = dlg.SelectedPath;
FazerBackup.Enabled = true;
}
}
Backup:
private void FazerBackup_Click(object sender, EventArgs e)
{
MySqlConnection conexao = ClassConexao.ObterConexao();
try
{
string data = conexao.Database.ToString();
string cmd = "backup database [" + data + "] to disk='" + textBox1.Text + "\" + "database" + "-" + DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss") + ".bak'";
using (MySqlCommand command = new MySqlCommand(cmd, conexao))
{
if (conexao.State != ConnectionState.Open)
{
conexao.Open();
}
command.ExecuteNonQuery();
conexao.Close();
MessageBox.Show("Sucesso");
}
}
catch (Exception error)
{
MessageBox.Show(String.Format("Check the fields {0}", error.Message));
return;
}
}
Connection is already open and Path (path) is already in the box.
Error:
Ps: Even straight into MySql - SQL Editor this syntax is not working; strange, because every tutorial I see, is exactly the same.