David Hooley
asked on
Backing up an Access 97 database which has a password
Hi,
I've been given a vb.net program to take over from another developer, which uses an Access 97 database. The user has asked me to put a password on the database to stop it being opened up at free will.
The program runs a daily backup of the database using the DAO Database engine. I'm not familiar with this, but at the moment, it cannot backup the database, as it keeps saying there's an invalid password.
Where do I put the password in this code, and how do I do it? (The error is on the dbo.CompactDatabase method)
Private Sub asyncBackupDaily(ByVal state As Object)
Try
sql = "SELECT * FROM [System Settings]"
dataAd = New OleDb.OleDbDataAdapter(sql , con)
dataSet = New DataSet
dataAd.Fill(dataSet)
Dim currentDB As String = readIni("DATABASE", directorypath & "settings.ini")
Dim newDB As String = dataSet.Tables(0).Rows(0). Item("back upPath") & "backup" & DateTime.Now.ToString("yyy y-dd-MM") & ".mdb"
My.Computer.FileSystem.Cop yFile(curr entDB, dataSet.Tables(0).Rows(0). Item("back upPath") & "backup" & DateTime.Now.ToString("yyy y-dd-MM") & "-nc.mdb", True)
If My.Computer.FileSystem.Fil eExists(ne wDB) = True Then
My.Computer.FileSystem.Del eteFile(ne wDB)
End If
Dim dbo As New DAO.DBEngine
dbo.CompactDatabase(dataSe t.Tables(0 ).Rows(0). Item("back upPath") & "backup" & DateTime.Now.ToString("yyy y-dd-MM") & "-nc.mdb", newDB)
Try
My.Computer.FileSystem.Del eteFile(da taSet.Tabl es(0).Rows (0).Item(" backupPath ") & "backup" & DateTime.Now.ToString("yyy y-dd-MM") & "-nc.mdb")
Catch ex As Exception
End Try
MsgBox("Daily auto-backup successful!", MsgBoxStyle.OkOnly, "Success")
Catch ex As Exception
errorLog(ex)
End Try
End Sub
I've been given a vb.net program to take over from another developer, which uses an Access 97 database. The user has asked me to put a password on the database to stop it being opened up at free will.
The program runs a daily backup of the database using the DAO Database engine. I'm not familiar with this, but at the moment, it cannot backup the database, as it keeps saying there's an invalid password.
Where do I put the password in this code, and how do I do it? (The error is on the dbo.CompactDatabase method)
Private Sub asyncBackupDaily(ByVal state As Object)
Try
sql = "SELECT * FROM [System Settings]"
dataAd = New OleDb.OleDbDataAdapter(sql
dataSet = New DataSet
dataAd.Fill(dataSet)
Dim currentDB As String = readIni("DATABASE", directorypath & "settings.ini")
Dim newDB As String = dataSet.Tables(0).Rows(0).
My.Computer.FileSystem.Cop
If My.Computer.FileSystem.Fil
My.Computer.FileSystem.Del
End If
Dim dbo As New DAO.DBEngine
dbo.CompactDatabase(dataSe
Try
My.Computer.FileSystem.Del
Catch ex As Exception
End Try
MsgBox("Daily auto-backup successful!", MsgBoxStyle.OkOnly, "Success")
Catch ex As Exception
errorLog(ex)
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.