Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Backing up an Access 97 database which has a password

Posted on 2016-08-31
2
13 Views
Last Modified: 2016-10-22
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("backupPath") & "backup" & DateTime.Now.ToString("yyyy-dd-MM") & ".mdb"

            My.Computer.FileSystem.CopyFile(currentDB, dataSet.Tables(0).Rows(0).Item("backupPath") & "backup" & DateTime.Now.ToString("yyyy-dd-MM") & "-nc.mdb", True)

            If My.Computer.FileSystem.FileExists(newDB) = True Then
                My.Computer.FileSystem.DeleteFile(newDB)
            End If

            Dim dbo As New DAO.DBEngine
            dbo.CompactDatabase(dataSet.Tables(0).Rows(0).Item("backupPath") & "backup" & DateTime.Now.ToString("yyyy-dd-MM") & "-nc.mdb", newDB)

            Try
                My.Computer.FileSystem.DeleteFile(dataSet.Tables(0).Rows(0).Item("backupPath") & "backup" & DateTime.Now.ToString("yyyy-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
0
Comment
Question by:David Hooley
2 Comments
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 41778163
There is a Microsoft KB article on one way to open it if i just a DB password, and not user level security. The sample code is:
 Dim db As DAO.Database
 Dim ws As DAO.WorkSpace
 Dim rst As DAO.Recordset
 Set ws = DBEngine.WorkSpaces(0)
 Set db = ws.OpenDatabase _
 ("C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb", _
 False, False, "MS Access;PWD=northwind")
 Set rst = db.OpenRecordset("Customers", dbOpenDynaset)
 If rst.RecordCount > 0 Then
   rst.MoveLast
   MsgBox rst!CustomerID
 End If

Open in new window

source: https://support.microsoft.com/en-us/kb/209953

Also with Oledb it will be in the connection string, which you don't show. (the con varible)
Here is how to do the connection strings (2007-2013:  
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
Jet OLEDB:Database Password=MyDbPassword;

Open in new window

source: http://www.connectionstrings.com/access/
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question