Could not use ''; file already in use

G

Guest

I've read a couple of threads on this error but none of them could help me so
I'm posting myself.

When I try open and read (not update) an ACCESS database on a network share
I occasionally get:

"Could not use ''; file already in use." error.

This always happens when the database is open but sometimes even when it's
not. Not manually anyway. I consequently use DataAdapter.Fill() method which
should close the connection, right? Anyway, It must work even when the
database is open (not design mode). It does so when I run the application
against a database on the webbserver. What's the difference when its on a
network share? The IUSR has full rights on the database-folder. And as I said
earlier it works, but not always so it's unlikely a basic security problem.
There must be some way to force ASP.NET to read an open database. Can anybody
please help me?

/Miro
 
R

Robbe Morris [C# MVP]

Access is not a good fit for web applications. I've seen your
error occur often times when you don't properly close
the connection "in every instance" and the lock file
gets left.
 
N

Norman Yuan

Even you said it worked earlier, still the most possible reason could the
user account running the ASP.NET appdoes not have read/write permission to
the *.mdb file. Before you can tell whether the folder where *.mdb is
licated is allowed full access to some users, you have to make sure who is
exactly access it. Are you sure the ASP.NET app or apps run with
IUSR_MachineName account? (By default. ASP.NET runs on ASPNET/Network
Service account, unless you set "impersonate=true" for the ASP.NET app or
apps.
 
G

Guest

Thanks!

Yes, I'm using impersonate=true to be absolutely sure that the user has full
rights on the folder. The database is on a Novell File Server and I had big
troubles get it working in the first place. Finally I got some expert-help
from Microsoft which solved it, for a while. Actually, it's not IUSR but som
new account created in both IIS and Novell. But I'm sure the account has full
rights.

/Miro
 
G

Guest

Thanks!

What must I do to be absolutely sure that the connection is closed. This is
the function I'm using:

public DataSet GetFromAccessDatabase(String SQLQuery)
{
OleDbConnection conn = new OleDbConnection(this._ConnectionString);
OleDbCommand select = new OleDbCommand(SQLQuery);
OleDbDataAdapter dataAD = new OleDbDataAdapter();
dataAD.SelectCommand = select;
select.Connection = conn;
DataSet mds = new DataSet();
dataAD.Fill(mds);
select.Connection.Close();
dataAD.Dispose();
conn.Dispose();
select.Dispose();
return mds;
}

Is it a good solution to try deleting the .ldb file before each database call?

One more thing. The database is on a Novell Server and I heard that
sometimes windows and Novell doesn't communicate to well and that perhaps
Novell never gets the message that the database is closed. Is this possible
and if so, what could be the workaround?

/Miro
 
Joined
May 24, 2009
Messages
1
Reaction score
0
Don't do anything else. The error comes because of lack of privileges

In most of the cases this error comes due to disabled impersonation in web.config file.

Add following things to enable impersonation in web.config file and your error will disappear.

<configuration>
<system.web>
<identity impersonate="true" />
</system.web>
</configuration>
 

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

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,836
Latest member
BuyBlissBitesCBD

Latest Threads

Top