Access can-t open the database error

T

tec-goblin

I have a C# application that uses access interop to do the following:
Microsoft.Office.Interop.Access.Application access = new
Microsoft.Office.Interop.Access.ApplicationClass();
access.AutomationSecurity =
Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow;
access.OpenCurrentDatabase(@"TG Client.mdb", false, string.Empty);

And I get
"Microsoft Office Access can't open the database because it is missing, or
opened exclusively by another user."

This happened to me on Vista (so it could be UAC? I didn't have any problems
with the creation of Word documents, though).
btw, I've checked other paths (TG Client is saved on the Debug\bin folder),
and of course I don't have the application open.

Any suggestions? Thanks in advance!
 
N

Norman Yuan

What type is your C# application? Win Form or Web app? If it is Win form,
can you try specify a full path+filename? If it is web app, ytou need to
give execute permission to the web app running user account, and it is
strongly recommended not automate MS Access with a server application.
 
T

tec-goblin

Norman Yuan said:
What type is your C# application? Win Form or Web app? If it is Win form,
can you try specify a full path+filename?
It is winForm and I tried a full path + filename already. (it is actually a
very long path, but it remains below 200 characters and a very similar one
works perfectly with Excel and Word interop). I also moved the application to
the root and tried with a simpler and smaller path, and still it didn't work.

Any ideas?
 
A

Arvin Meyer [MVP]

The other user could be you if you haven't cleaned up and closed your
recordsets, or there is a dangling .ldb file that Access can't get rid of.
Another possibility is that your permissions are not allowing an .ldb file
to be created, so Access will only allow the first instance in memory. The
..ldb file is how Access keeps track of record locks and you need to have
everything except Full Control on the folder where the application resides
in order to guarantee that there will not be a permissions problem.
 
T

tec-goblin

It was solved. It's funny, I might have had something open in the past, now
that I checked I had no ldb there, and I don't do anything with this database
except from the code you see above (and one more command that opens a report).
But what I saw is that after varios efforts, in the last one, I had
forgotten to write "\" between the path and the report (and it can be seen in
the above code).

So I suspect that something had remained open when I first tried to open the
database, then, after various "efforts" that something wasn't there any more,
but I had broken my code :p.
Problem solved (I hope for good).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top