954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Backup and Restore Database

I am currently using a database within my program and I have no problem backing it up or restoring it when i am simply debugging. However if it is published and downloaded it cannot find the path that it needs to get to the database to copy it. My code is:

Public Sub backupDB()

        Dim portfolioPath As String = My.Application.Info.DirectoryPath

        FileCopy(portfolioPath & "\Information Sources\portfolioDB.mdb", "C:\Program Files\PortfolioGen2.0\DBBACKUP.mdb")

        MsgBox("Backup Successful")
    End Sub

    Public Sub restoreDB()

        Dim portfolioPath As String = My.Application.Info.DirectoryPath

        If MessageBox.Show("Restoring the database will erase any changes you have made since you last backup. Are you sure you want to do this?", _
                    "Confirm Delete", _
                    MessageBoxButtons.OKCancel, _
                    MessageBoxIcon.Question, _
                    MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.OK Then
            'Restore the database from a backup copy.
            FileCopy("C:\Program Files\PortfolioGen2.0\DBBACKUP.mdb", portfolioPath & "\Information Sources\portfolioDB.mdb")

            MsgBox("Database Restoration Successful")
        End If

    End Sub


Any help is appreciated

Mr.Wobbles
Light Poster
49 posts since Jun 2007
Reputation Points: 10
Solved Threads: 2
 

Perhaps I didn't explain well enough. I need to know how to use relative paths that will work from within the program because apparently if I try to start from outside it cannot find the path (and neither can I by the way) So if there is a way to make what is installed on the computer more visible that would be ok too. I am looking for any solution really. I am using VB 2005 and XP. Thanks again

Mr.Wobbles
Light Poster
49 posts since Jun 2007
Reputation Points: 10
Solved Threads: 2
 

Look at SQLDMO?

Triss
Newbie Poster
15 posts since Nov 2007
Reputation Points: 10
Solved Threads: 1
 

Use SQL...

To backup ...

BACKUP DATABASE test TO DISK = 'c:\test.bak'


To Restore ...

RESTORE DATABASE test FROM DISK = 'c:\test.bak''
Triss
Newbie Poster
15 posts since Nov 2007
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You