Acces Database: Password Protected
-
Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD";
When I call:OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open();
The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated. -
Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD";
When I call:OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open();
The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.Ken Mazaika wrote:
The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll.
And what did the exception message say? That is quite important becuase there are many reasons it might throw an exception of that type.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website
-
Ken Mazaika wrote:
The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll.
And what did the exception message say? That is quite important becuase there are many reasons it might throw an exception of that type.
Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." My website
The message box said "Microsoft Development Environment" in the titlebar, the words "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll" and Break, Continue, Ignore (disabled), and Help buttons. The debugger highlights the line immediately following the Open(), which happens to be
return true;
thanks, -Ken -
Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD";
When I call:OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open();
The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.Just to eliminate an obvious error: I am assuming you are using the @ symbol at the beginning of your connection string assignment.
string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin; Password=P@$$w0rD";
If not, then you should be using a double backslash when listing your Source:Source=C:\\file.mdb;
-
Just to eliminate an obvious error: I am assuming you are using the @ symbol at the beginning of your connection string assignment.
string connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin; Password=P@$$w0rD";
If not, then you should be using a double backslash when listing your Source:Source=C:\\file.mdb;
Sorry, I did use a double backslash I just changed the code to a different path to be simpler. Thanks though, -Ken
-
Hi I'm looking to my queries to an Access database in C# that is password protected and I am having difficulties. The password is 13 characters long and contains capital, lowercase, symbols (#$%^) and numbers. My connection string looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\file.mdb;User ID=admin;Password=P@$$w0rD";
When I call:OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open();
The program crashes with an unhandled exception of type 'System.Data.OleDb.OleDbException in system.data.dll. I did some research and it says that C# handles special characters in a way that isn't compatible with some access databases. I'm not sure if $%^ are special characters, or if that means just unicode. Does anyone know where I'm slipping up or how to fix this? Any advice would be appreciated.I figured out the answer thanks to another user's post on a particular article here. To access a password protected database you can add another part to the connection string. I added this to the end of it and it works like a charm.
jet OLEDB:Database Password=mypassword;
I'm not sure why the password needs to be listed twice, but it seems to work. I also had issues doing this with Toolbox>Data>OleDbConnection wizard that matched my results pretty well. Hardcoding the connection string with that added fixes it though. -Ken