backup
-
Hi...there is problem in backup of database.Here i m providing the code.. try { DateTime Time = DateTime.Now; int year = Time.Year; int month = Time.Month; int day = Time.Day; int hour = Time.Hour; int minute = Time.Minute; int second = Time.Second; int millisecond = Time.Millisecond; //Save file to C:\ with the current date as a filename string path ; string p = saveFileDialog1.FileName; path = p + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql"; StreamWriter file = new StreamWriter(path); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump.exe"; psi.RedirectStandardInput = false; psi.RedirectStandardOutput = true; psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}", "root", "123456", "localhost", "userdb"); psi.UseShellExecute = false; Process process = Process.Start(psi); string output; output = process.StandardOutput.ReadToEnd(); file.WriteLine(output); process.WaitForExit(); file.Close(); process.Close(); MessageBox.Show("backup is created"); } catch (IOException ex) { MessageBox.Show("Error , unable to backup!"); } } } so the problem is when pointer reach to this line- Process process = Process.Start(psi) then an existing event is automatically called and i dont think that this event has to do anything with it....the event is this..
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
// if (tabControl1.TabPages.Count != 1){ e.Graphics.DrawString("x", e.Font, Brushes.Black, e.Bounds.Right - 15, e.Bounds.Top + 4); e.Graphics.DrawString(this.tabControl1.TabPages\[e.Index\].Text, e.Font, Brushes.Black, e.Bo
-
Hi...there is problem in backup of database.Here i m providing the code.. try { DateTime Time = DateTime.Now; int year = Time.Year; int month = Time.Month; int day = Time.Day; int hour = Time.Hour; int minute = Time.Minute; int second = Time.Second; int millisecond = Time.Millisecond; //Save file to C:\ with the current date as a filename string path ; string p = saveFileDialog1.FileName; path = p + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql"; StreamWriter file = new StreamWriter(path); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump.exe"; psi.RedirectStandardInput = false; psi.RedirectStandardOutput = true; psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}", "root", "123456", "localhost", "userdb"); psi.UseShellExecute = false; Process process = Process.Start(psi); string output; output = process.StandardOutput.ReadToEnd(); file.WriteLine(output); process.WaitForExit(); file.Close(); process.Close(); MessageBox.Show("backup is created"); } catch (IOException ex) { MessageBox.Show("Error , unable to backup!"); } } } so the problem is when pointer reach to this line- Process process = Process.Start(psi) then an existing event is automatically called and i dont think that this event has to do anything with it....the event is this..
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
// if (tabControl1.TabPages.Count != 1){ e.Graphics.DrawString("x", e.Font, Brushes.Black, e.Bounds.Right - 15, e.Bounds.Top + 4); e.Graphics.DrawString(this.tabControl1.TabPages\[e.Index\].Text, e.Font, Brushes.Black, e.Bo
The event has nothing to do with it as you stated; it merely redraws a tabitem. You're catching the output of the application that you're starting.
string output;
output = process.StandardOutput.ReadToEnd();What does the string "output" contain?
catch (IOException ex)
{
MessageBox.Show("Error , unable to backup!");
}Does it show this message? Can you check whether the code throws an exception? Change the errorhandler to something similar like below;
catch (IOException ex)
{
if (System.Diagnostics.Debugger.IsAttached())
{
Console.WriteLine(ex.ToString()); // paste the info that's shown here into your post
}
else
MessageBox.Show("Error , unable to backup!");
}Bastard Programmer from Hell :suss:
-
The event has nothing to do with it as you stated; it merely redraws a tabitem. You're catching the output of the application that you're starting.
string output;
output = process.StandardOutput.ReadToEnd();What does the string "output" contain?
catch (IOException ex)
{
MessageBox.Show("Error , unable to backup!");
}Does it show this message? Can you check whether the code throws an exception? Change the errorhandler to something similar like below;
catch (IOException ex)
{
if (System.Diagnostics.Debugger.IsAttached())
{
Console.WriteLine(ex.ToString()); // paste the info that's shown here into your post
}
else
MessageBox.Show("Error , unable to backup!");
}Bastard Programmer from Hell :suss:
Sir as u said i have pasted that code but the same thing is happening again.Again after that line code goes to that event dont know why....and one more think backfile is being created but there is nothing in the backup file because after that line code is not executing.....:(