Solved

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

Posted on 2006-06-20
14
374 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 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

12 Experts available now in Live!

Get 1:1 Help Now