CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Member
Join Date
Sep 2001
Posts
160

Can anyone help?

I can connect to my access 2k database without a password set in the databaase using an ado connection. If i try to connect with a password set I get an error. In the connection string i do not specify a user but i do specify a password "Password = pwd".

Can some one tell me what i am doing wrong or point me in the right direction.

Thanks,

Jason

2. Senior Member
Join Date
Sep 2001
Location
IL, USA
Posts
1,090
Code:
'Try the following code:
Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Conn.Open "Provider=MSDASQL;" & "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\new.mdb;" & "Uid=;" & "Pwd=pwd"
Debug.Print Conn.State
Conn.Close
Set Conn = Nothing
End Sub

3. Member +
Join Date
Jun 2002
Location
Clane, Ireland
Posts
766
This works for me:

Connection = Provider=Microsoft.Jet.OLEDB.4.0;Data Source = \\bifdomain1_pdc\it\jpart\KNOWLEDGE BASE.MDB;Jet OLEDB:System Database=\\bifdomain1_pdc\it\jpart\knowledge Base.MDW;User ID = USRUSR;Password=PWDPWDPWD;

.ConnectionString = connection
.Open
End With

USRUSR is the user id, and PWDPWDPWD is the password they have supplied.

4. Member +
Join Date
Jun 2002
Location
Clane, Ireland
Posts
766
If the database is just password protected, the following should work:

Connection = Provider=Microsoft.Jet.OLEDB.4.0;Data Source = \\bifdomain1_pdc\it\jpart\KNOWLEDGE BASE.MDB;Jet OLEDB:Database Password=PWDPWDPWD;

.ConnectionString = connection
.Open
End With

PWDPWDPWD is the database password.
Last edited by Cimperiali; July 29th, 2004 at 02:59 AM.

5. Member
Join Date
Mar 2002
Posts
70
Hi..
I have the same problem of theghost... I've created a database in Access97 (OS Windows 98) and I didn't use password. Then I tried an ADODB connection with VB6, and it work. But when I created a password for my database, I can't connect anymore...
I was looking for this Forum and I've found this answer but, I tried all the solutions and no one solve my problem... Do you have any other suggestion or can indicate me what can I be doing wrong?
Cristiane

6. Connecting to Password protected Access 97 with ADO

Hi
I am having the same problems as stated in Cristiane's post.

Any suggestions.

Thanks,
SB

7. Member
Join Date
Apr 2004
Posts
51
I was also having the same problem... and I finally found my answer... I'm sure this in some other posts...I just didn't recognize the format. Here is what I did.
Code:
set myConn = New ADODB.connection
with myConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "\myFilePath\myFile.mdb"
end with
this worked...

I was trying to pass the password in the open statement...but it was giving me a error....

hope this helps someone.

kenny
Last edited by Cimperiali; July 29th, 2004 at 03:01 AM. Reason: Adding Code tags and disabling smiles

8. Member +
Join Date
Jun 2002
Location
Clane, Ireland
Posts
766
You can do the same thing using a connection string. One of the easiest ways of setting up a connection string, is to create a UDL file to your database, filling in all the parameters. You can then open this file using notepad, and copy its contents into your connection string.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Click Here to Expand Forum to Full Width