CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: backup database

  1. #1
    Join Date
    Mar 2011
    Posts
    34

    backup database

    i got this code from the internet, but i dont know the process or flow of it, im looking for a button that can restore and save my sql database.

    i have backup.bat and restore.bat in a folder..
    but i dont know how to use them.



    Code:
    Private Sub cmdbackup_Click()
    If MsgBox("Please confirm creating back-up.", vbQuestion + vbYesNo, "") = vbYes Then
        Shell App.Path & "\Backup\backup.bat"
        MsgBox "Backup successfully created!", vbInformation
    
    End If
    End Sub
    
    Private Sub cmdRestore_Click()
    If MsgBox("Please confirm restoring back-up.", vbQuestion + vbYesNo, "") = vbYes Then
        Shell App.Path & "\Backup\restore.bat"
        MsgBox "Backup successfully restored!", vbInformation
    End If
    End Sub
    Last edited by jelopy15; July 14th, 2011 at 09:00 AM.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: backup database

    So what part of it do you not understand. The code is pretty simple. All it does it executes the bat files. In order for it to work as is the bat files must be contained in a sub folder named \backup off the main folder where your program resides.

    Assuming the bat files work then the program should work fine.

    The success message boxes are bogus though. They may well display before the backup is completed and they have no way of knowing if the procedure was successful or not.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: backup database

    Really depends on the TYPE of Database. SQL Server / Access / MySQL
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Mar 2011
    Posts
    34

    Re: backup database

    im using mysql.
    for example, im going to press the backup button..then its going to save it in the backup.bat..am i right? then,, does it mean that if i delete my database in mysql can i still recover them by just pressing the restore button?

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: backup database

    We have no idea what your bat file does so we can not tell you. The code you posted simply executes a bat file and says it worked regaurdless of what actually happens during execution of the bat file.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: backup database

    There is probably a CONSOLE command, or PROC that will do what you want. Most of us don't do MySQL. Access / Microsoft SQL Server (or Express) is the normal db
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: backup database

    I would think that the bat file is simply calling a console command.
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: backup database

    What worries me here is because the code was found on the internet, perhaps the bat files are set up wrongly for jelopy. I'd suggest to jelopy that he post the contents of the batch files here. You could do this by right clicking on the Bat file, and selecting Edit. It should open in Notepad. Show us what is insde them, please, just to be safe...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured