Emad,
Here is a solution you could try.
Have the installer include the .MDB file along with your other files in the same program folder.
Example, the user states in the installer that they want to install the software to
C:\Program Files\Company\Software\; so with that, the installer copies the software files, but
also a backup copy of the .MDB file - maybe in the path
C:\P...\Software\data\orginialdatabase.mdb
The reason for this, is that it will work with the following code - which you can incorporate in to your project in the
Form_Load procedure on the MAIN form:
Private Sub Form_Load()
Dim Directory As String = "C:"
'Check to see if the database exists.
If Not My.Computer.FileSystem.FileExists(Directory & "\database.mdb") Then
MsgBox("The database could not be found. The application will now replace a backup of the database.")
FileCopy(Application.StartupPath & "\data\database.mdb", Directory & "\database.mdb")
Else
MsgBox("The database was found: " & Directory & "\database.mdb")
End If
'INCLUDE HERE, OTHER FORM_LOAD CODE.
So here, you are using both a
backup copy and an
actual copy. Another addition to your software is that you could have the application, on exit, save a backup copy of the database just in case something goes wrong:
Private Sub Form_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim outFileName As String = "db_backup_" & Format(Date.Now, "ddMMyy_HHmm") & ".mdb"
FileCopy(Directory & "\database.mdb", Application.StartUpPath & "\data\backups\" & outFileName)
End Sub
I hope this has helped you with your problem.