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 mysql database using c#

backup mysql database using c#

Scheduled Pinned Locked Moved C#
databasehelpcsharpmysql
16 Posts 5 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.
  • A Abhinav S

    Try after adding mysqldump to environment variables (along with the path to it).

    A Offline
    A Offline
    altafmohd
    wrote on last edited by
    #7

    thank u sir ho gya :)

    A 1 Reply Last reply
    0
    • A altafmohd

      sir i am devloping a project mysql query browser .....so i will need you in future ....i hope you will be for my help .....if you have facebook account plz tell me i want to conncet wid you...thanx in advance

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #8

      A few things. 1. Unless somebody is really stupid and wants to attract a lot of spam, they tend not to give personal information out on the forums, especially to someone they don't know. 2. We are more than happy to help somebody with problems, but nobody on this forum has the time to start offering one to one help. 3. You'll find that we are much more willing to help people if they don't use text speak. It's deeply irritating to those of us who enjoy the full use of the keyboard.

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      A 1 Reply Last reply
      0
      • P Pete OHanlon

        A few things. 1. Unless somebody is really stupid and wants to attract a lot of spam, they tend not to give personal information out on the forums, especially to someone they don't know. 2. We are more than happy to help somebody with problems, but nobody on this forum has the time to start offering one to one help. 3. You'll find that we are much more willing to help people if they don't use text speak. It's deeply irritating to those of us who enjoy the full use of the keyboard.

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

        A Offline
        A Offline
        altafmohd
        wrote on last edited by
        #9

        OK SIR :)

        1 Reply Last reply
        0
        • A altafmohd

          thank u sir ho gya :)

          A Offline
          A Offline
          Abhinav S
          wrote on last edited by
          #10

          altafmohd wrote:

          ho gya

          Just for the benefit of the English community, this means "Its done". You might want to post in the GIT[^] if you want to use Hindi as your means to ask questions. Also, always vote if it helps.

          A 2 Replies Last reply
          0
          • A Abhinav S

            altafmohd wrote:

            ho gya

            Just for the benefit of the English community, this means "Its done". You might want to post in the GIT[^] if you want to use Hindi as your means to ask questions. Also, always vote if it helps.

            A Offline
            A Offline
            altafmohd
            wrote on last edited by
            #11

            ok sir ....and thank you :)

            1 Reply Last reply
            0
            • A altafmohd

              i m providing code which i am running and getting exception plz help in this regard thanx .... :) public void Backup() { // Process.Start("IExplore.exe"); 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; path = "C:\\MySqlBackup" + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql"; StreamWriter file = new StreamWriter(path); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "mysqldump"; 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); ///here is exception coming string output; output = process.StandardOutput.ReadToEnd(); file.WriteLine(output); process.WaitForExit(); file.Close(); process.Close(); } catch (IOException ex) { MessageBox.Show("Error , unable to backup!"); } } but when i run this code it is providing me runtime eroor exception ........".The system cannot find the file specified " at the line Process process = Process.Start(psi);

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #12

              No idea, but this:

              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;
              path = "C:\\MySqlBackup" + year + "-" + month + "-" + day +
              "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql";

              can be reduced to:

              string path = System.String.Format ( @"C:\MySqlBackup{0:yyyy-MM-dd-HH-mm-ss-fff}.sql" , System.DateTime.Now ) ;

              1 Reply Last reply
              0
              • W Wayne Gaylard

                Glad to help

                When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                A Offline
                A Offline
                altafmohd
                wrote on last edited by
                #13

                sir i want to provide path through " open file dialog box " ...how can i get the path where i want to save my backup file using this dialog box ...plz help thanx in advance .

                W 1 Reply Last reply
                0
                • A Abhinav S

                  altafmohd wrote:

                  ho gya

                  Just for the benefit of the English community, this means "Its done". You might want to post in the GIT[^] if you want to use Hindi as your means to ask questions. Also, always vote if it helps.

                  A Offline
                  A Offline
                  altafmohd
                  wrote on last edited by
                  #14

                  sir i want to provide path through " open file dialog box "
                  ...how can i get the path where i want to save my backup file using this dialog box ...plz help thanx in advance

                  1 Reply Last reply
                  0
                  • A altafmohd

                    sir i want to provide path through " open file dialog box " ...how can i get the path where i want to save my backup file using this dialog box ...plz help thanx in advance .

                    W Offline
                    W Offline
                    Wayne Gaylard
                    wrote on last edited by
                    #15

                    Use a FolderBrowserDialog[^].

                    When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                    A 1 Reply Last reply
                    0
                    • W Wayne Gaylard

                      Use a FolderBrowserDialog[^].

                      When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                      A Offline
                      A Offline
                      altafmohd
                      wrote on last edited by
                      #16

                      thank you :)

                      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