Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>private void TakeDBBackup() { string tables = ""; // Displaying tables from apman database var cmd = new MySqlCommand( "select table_name from information_schema.tables where table_schema='apman' and table_type like '%TABLE'", ClientConnection); MySqlDataReader read2 = cmd.ExecuteReader(); while (read2.Read()) // Initializing tables into a varible string. tables += read2["table_name"] + " "; read2.Close(); // Displays current date and time name as folder name. 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; // Creating Dumpdata directory string dest = Directory.GetCurrentDirectory() + "\\Dumpdata\\"; Directory.CreateDirectory(dest); string src = dest + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + ".sql"; var file = new StreamWriter(src); string cmd1 = string.Format("--force --user=root --password=passd apman &gt; {0} {1}", src, tables); var proc = new ProcessStartInfo(); proc.FileName = "mysqldump.exe"; proc.Arguments = cmd1; proc.RedirectStandardInput = true; proc.RedirectStandardOutput = true; proc.UseShellExecute = false; proc.RedirectStandardError = true; proc.CreateNoWindow = true; Process p = Process.Start(proc); string res = p.StandardOutput.ReadToEnd(); p.Start(); p.OutputDataReceived += (o, args) =&gt; File.AppendAllText(src, args.Data); file.WriteLine(res); //p.WaitForExit(); p.Close(); Console.WriteLine(@"Database backup is taken"); file.Close(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload