DB with MS Access password generates OleDbException

larkahn

Member
Joined
Sep 10, 2006
Messages
18
Programming Experience
1-3
In Access, I clicked File>Open>Open Exclusive>MyDatabaseName
I then clicked Tools>Set Password and then closed the database.

In VB .NET 2005, in the Server Explorer I right click on the database and then click on Modify Connection for the database. Under Advanced, I entered MyPassword in the property of JET OLEDB: Database Password. I then click OK and on the Modify Connection screen click on Test Connection. A Message Box pops up saying Test Connection Succeeded.

The problem occurs when running my program. On my main form, I click on a button which opens up an instance of the form that is bound to my database.

VB.NET:
Private Sub Button62_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button62.Click
 
        Dim myDictionaryfrm As New DictionaryMDBfrm
        myDictionaryfrm.Show()
        myDictionaryfrm.TopMost = True
        Me.Hide()
 
    End Sub
Here is the Load Form info for the database form:

VB.NET:
Private Sub DictionaryMDBfrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         Me.DictionaryTableAdapter.Fill(Me.PhoneterciseDBDataSet1.dictionary)
 
    End Sub
The above Me.Dictionary.... code generates the following error:
OleDbException was unhandled

The detail is: {"Not a valid password."}

As per a previous forum posting, http://www.vbdotnetforums.com/showthread.php?t=14276&highlight=password
I could find the code:
VB.NET:
Provider= Microsoft.Jet.OLEDB.4.0;Data Source = c:\mydatabase.mdb;Jet OLEDB; Database Password=MyDbPassword;
Since I am a low level programmer, I have very little coding other than using the various automatic code generation methods for binding my db, etc. I see no place in the various properties screens where I could actually enter this kind of connection string, other than modifying the password property as I have done.

Is there an easy way to solve this problem? Any assistance would be appreciated.
 
Go to project menu
Pick Proeprties
Click Settings tab
Look at the ConnectionString entry
Modify it
Remove any mention of a password in the password field, under user (which is set to "admin" i think)
In the advanced, ensure that the Database Password is set to your password

I could find the code:

Code:
Provider= Microsoft.Jet.OLEDB.4.0;Data Source = c:\mydatabase.mdb;Jet OLEDB; Database Password=MyDbPassword;

This connection string is mangled. It shouldnt say Jet OLEDB; Database Password

It should be a colon there. DOnt try and set it manually. If you found that connection string in your code, or settings, your connection string is mangled. Follow the steps above and you will succeed. Any further problems, return here and let me know how you get on..
 
Go to project menu
Pick Proeprties
Click Settings tab
Look at the ConnectionString entry
Modify it
Remove any mention of a password in the password field, under user (which is set to "admin" i think)
In the advanced, ensure that the Database Password is set to your password

Thanks very much!!! Had the same problem too and solve it by your steps.
Basically, mistake is the connection that we define at the OLEDB is the one that we manually call whilst the preset call for the read/write DB can be modified at the Project>Settings menu.

Thanks again!!!!
 
Mmm, more like the mistake is in assuming that making a connection in Server Explorer results in a project being able to connect to a database.. It doesnt.. To make the database available in the project, one muist add a Dataset, then drag tables out of server explorer and into the dataset.. Visual Studio will then transport the connection string correctly into the settings..
 
Back
Top