• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Cannot open password protected Access database from within Delphi 8 (.NET) ...

Okay, I have trawled EE and countless other sites, forums, etc and come to a shuddering halt.

I have recently migrated to Delphi 8 (.NET) from Delphi 7.  I used to connect to Access dbs using ADO components, which was easy and worked.

Now I am trying to connect to a password protected Access database in a WinForm project from within Delphi 8.  I specify the connection string, which when opening an unsecured database works fine.

When I try to open a passworded database, I get the following message from within the debug inspector ...

"Cannot start your application.  The workgroup information file is missing or opened exclusively by another user."

There are a few forum threads for this problem, but they either get resolved due to bad syntax in the connection string, or get left without a resolution.

I think my connection string is okay.  This is it ...

'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\afs.mdb;user id=admin;database password=mypassword'

I am tearing my hair out, as all my applications talk to Access databases, and I currently cannot run even the simplest of them.

I have a hunch it could be something to do with the system.mdw file which houses the basic user permissions when starting Access.  I have tried creating a new one through the security wizard within Access, but that doesn't seem to have worked.

Any help would be greatly appreciated.
0
JustinByrom
Asked:
JustinByrom
  • 6
  • 6
  • 2
1 Solution
 
atul_parmarCommented:
Try using connection builder. it opens up the data link properties where you can build and test the connection string.
0
 
JustinByromAuthor Commented:
Atul,

Done that.  Every time I 'Test' the connection, it does the same thing and gives me the error message.
0
 
mikelittlewoodCommented:
have you got the tick box in the connection builder set to save password if you are doing this?
Should be the parameter 'Persist Security Info=True'
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
JustinByromAuthor Commented:
Mike,

Thanks to you, we have progress of sorts ...

Having added in that extra parameter, I now get the 'Could not find installable ISAM' message, which I was also getting earlier on in my quest.

That took me down the route of the 'system.mdw' hunch.  I think that is something to do with it, as I have gone through the microsoft support site and explored the solutions to the 'Could not find installable ISAM' message.  None of them resolved the issue.
0
 
atul_parmarCommented:
Got it!

  ADOConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\afs.mdb;user id=admin;database';
  ADOConnection1.Properties.Refresh;
  ADOConnection1.Properties.Item['Jet OLEDB:Database Password'].Value := 'mypassword';
  ADOConnection1.Open;
0
 
atul_parmarCommented:
As you can see the solution is to remove the password from the connection string and set it using the adoconnection property.
0
 
JustinByromAuthor Commented:
Atul,

This is the snippet of code that I am executing ...

...
var
  Cn : OleDBConnection;
  DA : OleDbDataAdapter;
  Ds : DataSet;
begin
  Cn := OleDbconnection.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\afs.mdb;user id=admin;database password=mypassword;Persist Security Info=True');
  cn := OleDbDataAdapter.Create('select * from client',cn);
  ds := Dataset.Create();

  da.Fill(ds,'client');
  dataGrid1.DataSource := ds.Tables['client'];
end;

It would've been helpful of me to say that I am using OleDBConnection ...
0
 
JustinByromAuthor Commented:
Got to pop out for an hour or so, but will return shortly ...

All help is VERY much appreciated - thanks
0
 
atul_parmarCommented:
mate, OleDBConnection doesn't have properties collection.

In your case you will need the following connection string.

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\afs.mdb;Persist Security Info=False;Jet OLEDB:Database Password=mypassword

to build it yourself do not assign the password in data link properties connection tab. Instead go to All tab, select the Jet OLEDB:Database Password entry and click edit value then provide the password there. Test the connection.
0
 
mikelittlewoodCommented:
Any reason why you are using an OleDBConnection?
Why not use a TADOConnection object instead as this will connect to an access database no problem using the connection string from before.
0
 
atul_parmarCommented:
Mike, TADOConnection will also cause the same problem.
0
 
JustinByromAuthor Commented:
Atul,

Okay, now I get 'You do not have the necessary permissions to use the 'c:\test\afs.mdb' object. ...' error message.

I think we are making progress though.
0
 
JustinByromAuthor Commented:
Atul, you're a bl**dy genius!!!

That last bit was my mistake, as I'd screwed around with the security permissions on the mdb as a last resort about 20 mins ago.

I just replaced it with an earlier (unmodified) version, and it has worked.

Fantastic.  I have been battling this since yesterday morning and it has driven me up the wall.

Points to you mate.  Thanks.
0
 
atul_parmarCommented:
Thanks. :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now