I try to get backup to my database. My code is
private void button1_Click(object sender, EventArgs e)
{
string Coonstring = "datasource=localhost;port=3306;username=****;password=****;Charset=utf8";
MySqlConnection cn= new MySqlConnection(Coonstring);
MySqlCommand cmd;
SaveFileDialog sf = new SaveFileDialog();
sf.Filter = "Backup Files (*.Bak) |*.bak";
if(sf.ShowDialog()==DialogResult.OK)
{
cmd = new MySqlCommand("Backup Database project To Disk='" + sf.FileName + "'", cn);
cn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Done");
cn.Close();
}
}
but when i run it i get error
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Backup Database project To Disk='C:\Users\tariq emad\Desktop\1\tt.bak'' at line 1).
So, any one can help me to fix this error.