Solved

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

Posted on 2006-06-20
14
373 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

11 Experts available now in Live!

Get 1:1 Help Now