views:

378

answers:

4

Hi,

I'm trying to use to different methods of connecting to a database to edit data, the declaration below is working:

Dim rsConn As ADODB.Connection

rsConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& Application.StartupPath & "\VFMS_DB.mdb;" _
& "Jet OLEDB:System Database=Security.mdw", "Ads", "1234")

but now I want to do the same thing with the declaration below but I keep getting the message "Not a valid account name or password.

Dim conn As OleDbConnection

conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& Application.StartupPath & "\VFMS_DB.mdb;" _
& "Jet OLEDB:System Database=Security.mdw;Database Account=Ads;Database Password=1234;")

I pretty sure it's because of this ;Database Account=Ads;Database Password=1234; not being correct. I tried ;User ID=Ads;Database Password=1234; and also to make it look like the first statement but neither worked.

If anyone can please assist. Thank You

A: 

According to connectionstrings.com, this is the right connection string for a Jet OLE DB 4.0 connection with username and password:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;

Tomalak
A: 

Have you tried with user id and just password?

Russ Cam
A: 

Try using the User ID and Password keywords instead of Database Account and Database Password:

conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
         & Application.StartupPath & "\VFMS_DB.mdb;" & _
         "Jet OLEDB:System Database=Security.mdw;User ID=Ads;Password=1234;")

This is according to an example that I found on connectionstrings.com.

Guffa
A: 

I don't know the actual answer to your problem, but would point out that there is a potential for confusion here. There are two different types of "passwords" with Jet, the database password and the Jet user-level security password. The former involves no username (the database has a single password for everyone), while the latter has username/password pairing.

Jet ULS is always in effect, at all times. The default setup with Jet is a username of "admin" with no password defined. If someone has defined a password for the admin account, you'll need to provide it, or use an account whose password you know.

Last of all, the Jet ULS information is kept in a workgroup file, usually named system.mdw, and you may need to specify that in your connection string if the security settings for the MDB you're attempting to access are stored in a workgroup file other than the one defined as the system's default workgroup file. I'm not certain how ADO/OLEDB interacts with the default workgroup location settings in the registry, so I'd suggest finding out what the parameter name is for it and specifying it explicitly in all cases.

David-W-Fenton