944,044 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 34347
  • C# RSS
Jul 29th, 2007
0

Connecting password protected MS Access database from C#

Expand Post »
Hi,
I have an MS Access database which has password. Now I can open the database using the password from MS Access, but when I try to test connection from Visual Studio Connection String Settings Design Time Windows Form, I get message that "Not a valid password". Still, I tried to connect to that password protected MS Access database from C# using the connection string with password, and then when I run the application, I get Database Connection error message. Is there anything I am missing ? Would you please help me.

Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
emran834 is offline Offline
3 posts
since Jul 2007
Jul 30th, 2007
0

Re: Connecting password protected MS Access database from C#

I have a few questions?
  1. What version of Access?
  2. Are you using OLEDB or ODBC?
  3. Can you post your connection string?
The connection string should look like this for Access 2007 with a password.
C# Syntax (Toggle Plain Text)
  1. Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\mydb.accdb;Jet OLEDB:Database Password=password;
Standard security with ODBC should look like this for other versions of Access.
C# Syntax (Toggle Plain Text)
  1. Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=password;
Standard security with OLEDB should look like this.
C# Syntax (Toggle Plain Text)
  1. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydb.mdb;User Id=admin;Password=password;
And with just a database password, the OLEDB connection string should look like this:
C# Syntax (Toggle Plain Text)
  1. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydb.mdb;Jet OLEDB:Database Password=password;
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Jul 30th, 2007
0

Re: Connecting password protected MS Access database from C#

Hi Hamrick,

Thanks a lot for your help. Finally I found the problem, I changed my password and now it was working. So, I am assuming that, Ms Access cant take longer than a certain length password or some special character or maybe something else. But I am happy, my new password is working now.

Regards
Emran
Reputation Points: 10
Solved Threads: 0
Newbie Poster
emran834 is offline Offline
3 posts
since Jul 2007
Jul 30th, 2007
0

Re: Connecting password protected MS Access database from C#

That's funky. I looked around and found application limits for access 97 and 2000. I guess they're the same or better for newer versions, and if they're better it's probably a good idea to assume they're not for compatibility.

Access 97:
  • Max mdb file size: 1GB
  • Max objects in database: 32768
  • Max modules in database: 1024
  • Max object name length: 64
  • Max password length: 14
  • Max user/group name length: 20
  • Max users connected to database: 255
  • Max record length (without Memos and BLOBs): 2048
  • Max fields in table: 255
  • Max nested transactions: 7

MS Access 2000:
  • Max mdb file size: 2GB
  • Max table size: 1GB
  • Max objects in database: 32768
  • Max modules in database: 1000
  • Max object name length: 64
  • Max password length: 14
  • Max user/group name length: 20
  • Max users connected to database: 255
  • Max record length (without Memos and BLOBs): 2048
  • Max fields in table: 255
I guess your password was more than 14 characters? If not it probably had some special characters that access doesn't like.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Jul 30th, 2007
0

Re: Connecting password protected MS Access database from C#

Hi,
Thanks again,.

I am still confused about a matter. If my password was longer than 14 characters, then anytime ACCESS should not have accepted the password, right ? But I could easily open the MS Access using that old password directly from the MS ACCESS application itself. But when I tried to connect to the same database using the same password thru the ConnectionString from C# Windows Application, I used to get "Not a valid password.". Is it supposed to be different for one in MS Access application (itself) and another from external application connection !!

Anyway, I appreciate your helps.

Regards
Emran
Reputation Points: 10
Solved Threads: 0
Newbie Poster
emran834 is offline Offline
3 posts
since Jul 2007
Jul 30th, 2007
0

Re: Connecting password protected MS Access database from C#

Quote ...
I used to get "Not a valid password."
You aren't using it anymore, right? What was the password? I'm thinking it might have a special character that's treated differently in C# strings and translates into something not valid. That's just a guess though.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Feb 2nd, 2010
0

Thanks

Hi
Your guidance is really helpful to me Thanks.

Regards
Viral

Click to Expand / Collapse  Quote originally posted by Hamrick ...
I have a few questions?
  1. What version of Access?
  2. Are you using OLEDB or ODBC?
  3. Can you post your connection string?
The connection string should look like this for Access 2007 with a password.
C# Syntax (Toggle Plain Text)
  1. Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\mydb.accdb;Jet OLEDB:Database Password=password;
Standard security with ODBC should look like this for other versions of Access.
C# Syntax (Toggle Plain Text)
  1. Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=password;
Standard security with OLEDB should look like this.
C# Syntax (Toggle Plain Text)
  1. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydb.mdb;User Id=admin;Password=password;
And with just a database password, the OLEDB connection string should look like this:
C# Syntax (Toggle Plain Text)
  1. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydb.mdb;Jet OLEDB:Database Password=password;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vikibhatt is offline Offline
1 posts
since Feb 2010
Aug 9th, 2010
0

Error with secure connection

Could you tell me please how it worked with you?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
propatrio is offline Offline
1 posts
since Aug 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Add items to Combobox
Next Thread in C# Forum Timeline: Is C# 3.0 compatible with Visual Studio 2010





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC