Solved

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

Posted on 2006-06-20
14
375 Views
Last Modified: 2010-04-05
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
Comment
Question by:JustinByrom
  • 6
  • 6
  • 2
14 Comments
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16941235
Try using connection builder. it opens up the data link properties where you can build and test the connection string.
0
 
LVL 1

Author Comment

by:JustinByrom
ID: 16941259
Atul,

Done that.  Every time I 'Test' the connection, it does the same thing and gives me the error message.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16941358
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:JustinByrom
ID: 16941413
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
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16941451
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
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16941476
As you can see the solution is to remove the password from the connection string and set it using the adoconnection property.
0
 
LVL 1

Author Comment

by:JustinByrom
ID: 16941530
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
 
LVL 1

Author Comment

by:JustinByrom
ID: 16941540
Got to pop out for an hour or so, but will return shortly ...

All help is VERY much appreciated - thanks
0
 
LVL 10

Accepted Solution

by:
atul_parmar earned 500 total points
ID: 16941624
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
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16941729
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
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16941747
Mike, TADOConnection will also cause the same problem.
0
 
LVL 1

Author Comment

by:JustinByrom
ID: 16942172
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
 
LVL 1

Author Comment

by:JustinByrom
ID: 16942200
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
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16942225
Thanks. :)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now