Connect to access database using account name and password
I am trying to use two different database connection methods for editing data, working below:
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 with the ad below, but I keep getting the message "Invalid 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 am sure that because of this ;Database Account=Ads;Database Password=1234;
it is not correct. I tried ;User ID=Ads;Database Password=1234;
and also make it look like the first operator but didn't work.
If anyone can help. Thank you.
Try using keywords User ID
and Password
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 matches the example I found at connectionstrings.com .
a source to share
According to connectionstrings.com , this is the correct connection string for 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;
a source to share
I don't know the actual answer to your problem, but would like to point out that there is confusion here. There are two different types of passwords with Jet, the database password and the Jet user level security password. The former does not contain a username (each database has one password for all) and the latter has a username and password.
Jet ULS always works, always. The default setting with Jet is "admin" with no password. If someone has defined a password for the administrator account, you need to provide it or use an account for which you know the password.
Last but not least, Jet ULS data is stored in a workgroup file, usually named system.mdw, and you may need to specify this in the connection string if the security settings for the MDB you are trying to access are stored. in a workgroup file other than the file defined as the default workgroup file. I'm not sure how ADO / OLEDB interacts with the default workgroup location settings in the registry, so I would suggest figuring out what the parameter name is for and explicitly specifying it in all cases.
a source to share