database file locked by aspx

H

hkappleorange

I ued this code to connect to a mdb file




A = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
Source=C:\Inetpub\wwwroot\ASPX\Authors.mdb" )



However, I found the Access Mdb file is locked and cannot be edited by
Access even I have closed the connection using



A.Close()



The file is simply locked.



How to avoid this problem and how to fix it ??
 
S

S. Justin Gengo

Do you have the access database open in it's own window while trying to run
against it?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
H

hkappleorange

Thanks for replying. I have already closed the Access when I run the aspx
file. After running this aspx file, I found I cannot open the mdb file using
Access. I cannot access even I closed all IE windows... help ....

Is there something I should do in the code to avoid this problem ??

Many thanks.
 
S

S. Justin Gengo

Ok,

And is this happening after you get data out of the database the first time?

If, for example, you access your data via a datareader you have to close
the datareader afterward. Also, if an error occurrs while the datareader is
open you need to make certain to use a try catch finally structure and close
the reader in the finally section in order to make certain that it closes
properly each time.

E.g.

Try
'---Open data reader and do some things with the data (while the
datareader is open the database is locked)
Catch ex As Exception
'---Handle any exceptions that may occurr
Finally
'---Close the data reader so that the database is no longer locked
End Try

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
N

neilmcguigan

when using Access, I create a folder, called Data, and put the db in
there. I then set modify permissions on the whole folder

access creates a lock file, which goes in this folder. you want modify
permissions on this file, but it doesn't exist til access is run.

either way, doing this allows you to have access open while asp.net is
using it.

you might have to restart your asp.net worker process to unlock the
file.

thx
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top