I need to open a password-protected Access 2010 database from a VB2010 application. The connection works fine without a password, so I know I have all other parameters set correctly. But when I add the password to the connection string I get an error, "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." I know the password is correct because it works when I copy and paste it into the password dialog when opening the database directly in Access.
Here is the code I use. The error occurs at the adapter.fill command:
Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=" + Application.StartupPath + "\MyData.accdb;Jet OLEDB:Database Password=MyPassword;")
Dim command As OleDbCommand = New OleDbCommand()
command.Connection = conn
command.CommandText = "SELECT * FROM MyTable"
Dim table As DataTable = New DataTable()
Dim adapter As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(command)
adapter.Fill(table)