Last post Jun 16, 2008 04:47 AM by TimTrott
Jun 13, 2008 10:40 AM|TimTrott|LINK
I am trying to connect to an access database file. I have manually created a connection which works fine using the code below:
string _connectionStringData = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Path.GetDirectoryName(Application.ExecutablePath) + "\\testdb.accdb;Jet OLEDB:Database Password=qwerty321;";
using (OleDbConnection DbConnection = new OleDbConnection(_connectionStringData))
OleDbCommand DbCommand = DbConnection.CreateCommand();
DbCommand.CommandText = "SELECT * FROM Regions ORDER BY Sequence";
OleDbDataAdapter da = new OleDbDataAdapter(DbCommand);
This works fine. Now I am trying to add a connection into server explorer so that I can setup some typed datasets, but it keeps popping up messages telling me "Cannot start your application. The workgroup information file is missing or opened exclusively by another user."
I am using ".NET Framework Data Provider for OLE DB" as the datasource, "Microsoft Office 12.0 Access Database Engine OLE Provider". No username and password of qwerty321 as per my connection string.
If I go into the advanced properties, I looked for Jet OLEDB:Database Password property, but can't find it.
If I change the connection string in my code from "Jet OLEDB:Database Password=qwerty321" to "User Id=;Password=qwerty321;" I get the same error when connecting. Seems like I need to specify my own connection string instead of those stupid wizards!
Any help please?
Thanks in advance
Jun 13, 2008 04:12 PM|Mikesdotnetting|LINK
You could try doing without the security. If you place the database in the App_Data folder, it is safe from the possibility of it being downloaded. Other than that, the security mechanism on an Access database is not much more than a padlock, and is no
prevention to a determined person trying to get into it - and they would need to have access to the web server's file system to do so. If your data really is that sensitive, you should be using SQL Server instead.
For the large part, these wizards are flaky at best with Access, so setting the connection string manually may be your only option.
Jun 16, 2008 04:47 AM|TimTrott|LINK
Sorry, should have explained a bit better.
This is a win forms app, I guess the problem and fix is the same for asp. Database has been developed by another developer and I'm stuck with the access database. Not that i'm complaining - they wated to use an excel spreadsheet!
I think I may have found a solution now, I can ODBC connection to create my datasets, while the app uses OleDb at runtime.
Thanks for your help