Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. backup problem

backup problem

Scheduled Pinned Locked Moved C#
databasehelpmysqlgraphicssysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nitish_07
    wrote on last edited by
    #1

    Hi...I didnt get a proper reply thats why i m posting it again....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) { if (System.Diagnostics.Debugger.IsAttached()) { Console.WriteLine(ex.ToString()); } else 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.Bounds.Left + 12, e.Bounds.Top + 4); e.DrawFocusRectangle(); } } so because of this i m unable to create a proper backup file...so plz give some suggestion....

    L 1 Reply Last reply
    0
    • N nitish_07

      Hi...I didnt get a proper reply thats why i m posting it again....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) { if (System.Diagnostics.Debugger.IsAttached()) { Console.WriteLine(ex.ToString()); } else 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.Bounds.Left + 12, e.Bounds.Top + 4); e.DrawFocusRectangle(); } } so because of this i m unable to create a proper backup file...so plz give some suggestion....

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Your code calls MessageBox.Show, which obscures (part of) (one of) your app's windows; when you close the MessageBox, whatever was obscured needs repainting, that seems like why you are getting such event(s). Test the hypothesis by writing your messages to a file, or to a ListBox on your Window, rather than using MessageBox. In fact, I recommend to do that anyway, MessageBoxes are pretty annoying, while logging is very useful during development and afterwards. :) And please start using <PRE> tags (e.g.use the "code" widget) when showing code; it preserves formatting and improves readability.

      Luc Pattyn [My Articles] Nil Volentibus Arduum

      N 1 Reply Last reply
      0
      • L Luc Pattyn

        Your code calls MessageBox.Show, which obscures (part of) (one of) your app's windows; when you close the MessageBox, whatever was obscured needs repainting, that seems like why you are getting such event(s). Test the hypothesis by writing your messages to a file, or to a ListBox on your Window, rather than using MessageBox. In fact, I recommend to do that anyway, MessageBoxes are pretty annoying, while logging is very useful during development and afterwards. :) And please start using <PRE> tags (e.g.use the "code" widget) when showing code; it preserves formatting and improves readability.

        Luc Pattyn [My Articles] Nil Volentibus Arduum

        N Offline
        N Offline
        nitish_07
        wrote on last edited by
        #3

        Actually sir the thing is that event will also be called when code exit out of backup....so i think thats not an issue....The main thing is, the line

        Process process=Process.Start(psi);

        is not executing....and after this line i m getting error.....

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups