views:

236

answers:

3

Hi,

I have the following code where I make an copy of my database that I use. the code executes 100% but the problem I have is I'm not able to access my database afterward.I get a "Cannot start your application. The workgroup information file is missing or opened exclusively by another user." and so if I restart the application it all works fine again.

I'm certain the reason is because I can only access that database using a specific account name and password which is not account I'm logged in with.

What i want to try is to default that database mdb to the point where no user is accessing it, or to reassign the the only account name that can access it to that database mdb.

Any ideas, will be enormously appreciated? I've tried playing around with file security but had no luck.

    Private Sub cmdBackup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBackup.Click
        BackupDialogDB.DefaultExt = ".mdb"
        BackupDialogDB.InitialDirectory = "c:\"
        'SaveFileDialog1.ShowDialog()

        If BackupDialogDB.ShowDialog() = Windows.Forms.DialogResult.OK Then

            Try

                Dim sDBFile As String = Application.StartupPath + "\VFMS_DB.mdb"

                Dim sBackUpFile As String = BackupDialogDB.FileName


                'First check the file u want to compact exists or not
                If File.Exists(sDBFile) Then
                    If Not File.Exists(sBackUpFile) Then
                        File.Copy(sDBFile, sBackUpFile)
                    Else
                        File.Delete(sBackUpFile)
                        File.Copy(sDBFile, sBackUpFile)
                    End If

                    MessageBox.Show("The database was successfully backedup to: " + sBackUpFile , "Database Backedup", MessageBoxButtons.OK, MessageBoxIcon.Information)

                    sDBFile = ""
                Else
                    MessageBox.Show("There is no database to backup. Please restore from a backup", "Database Backup Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub
A: 

Do you have write permission in the target directory? Access needs to create a .ldb file along side the .mdb.

Otherwise, you can try some of the stuff here: http://www.xlinesoft.com/asprunnerpro/docs/error_the_microsoft_jet_database_engine_cannot%20open%20the%20file%20(unknown).htm

steamer25
+1  A: 

You should also copy and/or restore the workgroup information file.

Mark Brackett
it works, thanks
Domitius
A: 

Was the Database open when you copied it? Access creates lock files, *.ldb in the same directory the database is in, you might want to check for that file before you copy the database.