title: how to backup the database using mysql and c#.net
body: <p>I have found this solution for back up my database (mysql) using c#.net</p>
  
  <pre><code>string fname = txtFileName.Text;
  
  
  if (fname == "")
  {
  
   MessageBox.Show("Please Enter the File Name!");return;
  }
  
  try
  {
  
        btnBackup.Enabled = false;
        DateTime backupTime = DateTime.Now;
  
        int year = backupTime.Year;
        int month = backupTime.Month;
  
        int day = backupTime.Day;
       int hour = backupTime.Hour;
  
        int minute = backupTime.Minute;
       int second = backupTime.Second;
  
       int ms = backupTime.Millisecond;
      String tmestr = backupTime.ToString();
  
   // C:\Program Files\MySQL\MySQL Server 5.0\bin
  
     //tmestr = "C:\\" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + ".bak";
  
      tmestr = "C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\" + fname + year + "-" + month + "-" + day + "-" + hour;// +".sql";
  
     StreamWriter file = new StreamWriter(tmestr);
    ProcessStartInfo proc = new ProcessStartInfo();
  
      string cmd = string.Format(@"-u{0} -p{1} -h{2} {3}", user, passwd1, Data_Source, dbname);
       proc.FileName = "mysqldump";
  
     proc.RedirectStandardInput = false;
     proc.RedirectStandardOutput = true;
  
     proc.Arguments = cmd;//"-u root -p smartdb &gt; testdb.sql";
  
     proc.UseShellExecute = false;
     Process p = Process.Start(proc);
  
     string res;
     res = p.StandardOutput.ReadToEnd();
  
    file.WriteLine(res);
  
     p.WaitForExit();
  
    file.Close();
  
    MessageBox.Show("DataBase Backup Has Been Completed Successfully!");btnBackup.Enabled = true;
  }
  
  catch (IOException ex)
  {
  
    MessageBox.Show("Disk full or other IO error , unable to backup!");
  }
  
  txtFileName.Text = "";
  </code></pre>
  
  <p>which value i have to give in  this text box  <code>"txtfilename.txt"</code> </p>
  
  <p>and what i have to give in this values <code>@"-u{0} -p{1} -h{2} {3}", user, passwd1, Data_Source, dbname</code></p>
  
  <p>I have found the mysqldump.exe file in this location </p>
  
  <pre><code>string location = "C:\\Program Files\\MySQL\\MySQL WorkBench 5.2CE\\";
  </code></pre>
  
  <p>and this is my connectionstring </p>
  
  <pre><code>string connestring = "server=localhost;user=root;database=access";
  </code></pre>
  
  <p>I am not sure which values i have to give in these places  <code>user, passwd1, Data_Source, dbname</code> </p>
  
  <p>would any one pls help on this guys</p>
  
  <p>Many thanks..</p>