System.Data.OleDb.OleDbException: Could not use ''; file already in use

mazlina

Member
Joined
Aug 25, 2003
Messages
13
Location
malaysia
I am working on a little application, aspx pages and web services. I use MS Access for a database. All the time I try to get the results of a query I get the following error:

Could not use ; file already in use.
Exception Details: System.Data.OleDb.OleDbException: Could not use ; file already in use

Stack Trace:


[OleDbException (0x80004005): Could not use ; file already in use.]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
System.Data.OleDb.OleDbConnection.InitializeProvider()
System.Data.OleDb.OleDbConnection.Open()
TimeManagement.FormLogin.Page_Transfer(Object sender, EventArgs e) in c:\inetpub\wwwroot\TimeManagement\FormLogin.aspx.vb:66
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()



The database is neither open nor used by someone else. I am very greatful for some advice!
 
Sub Page_Transfer(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim staff As String
Dim status As String
Dim name As String
Dim strOutput As String

connection

myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Inetpub\wwwroot\TimeManagement\AttendanceReport.mdb;")

myCommand = New OleDbCommand("select * from TableUserPassword where UserStaffID = " & txtStaffID.Text & " and UserPassword = " & txtPassword.Text & " ", myConnection)

myConnection.Open()

Dim myDataReader As OleDbDataReader = myCommand.ExecuteReader

While myDataReader.Read

If myDataReader("UserStaffID") = txtStaffID.Text And myDataReader("UserPassword") = txtPassword.Text Then

Session("status") = myDataReader.Item("Status")
Session("StaffID") = txtStaffID.Text
Session("UserName") = myDataReader.Item("UserName")

status = Session("status")
staff = Session("StaffID")
name = Session("UserName")

context.Items("txtStaffID") = txtStaffID.Text
context.Items("txtPassword") = txtPassword.Text

LogUser(name, "IN")

Server.Transfer("framePage.aspx")


End If
End While

alert.Text = "Error Login!!"

myDataReader.Close()
myConnection.Close()

End Sub
 
Mazlina

First of all check if your database is open in Access

If it is not, then press Ctrl + Shift + Esc and check the process aspnet_wp.exe and end that process.

Usually the error you get is because the database file is being used by a certain application.

Now also make sure that you close all open connections when you finish executing the code that needs the databse.

Hope this helps,
 
ive check the process aspnet_wp.exe and end that process. but it still didnt work.....is there any other possible error that ive done?
 
i havent yet try using myCommand.dispose but i do try to give permission for everyone in my database folder allowed write and modify and its work. could it be the main problem actually?
 
I am not sure this is the problem or else the error message you had would be Access Denied, not file already in use.
 
This problem usually shows up if MSAccess DB is used.
These are somethings that you may wish to try
1. Open and close MS-Access application
2. Ensure Command.Dispose is called
3. Ensure connection is closed at the end of every new execution (using is a better option then open and close connection)
4. Before testing your application from IIS, close your Visual Studio, restart IIS and test
 
Back
Top