Solved

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

Posted on 2006-06-20
14
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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