0

When I try to backup mysql database I am not getting ExportToFile instead its showing export in the line shown as comment statement. How could I achieve that?

Here is my code:

private void Backup()
{
   string constring = "server=localhost;user=root;pwd=;database=testdb;Allow Zero Datetime=true";
   string file = "D:\\sss.sql";

   MySqlConnection conn = new MySqlConnection(constring);
   MySqlCommand cmd = new MySqlCommand();
   MySqlBackup mb = new MySqlBackup(cmd);

   cmd.Connection = conn;
   conn.Open();
   mb.Export(file);  //mb.ExportToFile//                   
   conn.Close();
}
Hassan
  • 5,360
  • 2
  • 22
  • 35
user3541403
  • 247
  • 1
  • 3
  • 18
  • How you tried ExportToFile? what it says when you do that `mb.ExportToFile(file)`? – Hassan May 02 '14 at 07:30
  • have you checked [this](http://stackoverflow.com/questions/17030331/execute-sql-script-on-sql-server-using-c-sharp) thread ? – Kurubaran May 02 '14 at 07:52
  • "Object reference not set to an instance of an object."the following error is thrown at line MySqlBackup mb = new MySqlBackup(cmd); – user3541403 May 02 '14 at 08:54
  • Error 14 'MySql.Data.MySqlClient.MySqlBackup' does not contain a definition for 'exporttofile' and no extension method 'exporttofile' accepting a first argument of type 'MySql.Data.MySqlClient.MySqlBackup' could be found (are you missing a using directive or an assembly reference?) – user3541403 May 02 '14 at 08:55

0 Answers0