Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

  • *Experts*
Posted

Could we see the method that contains the line of code that

causes this error?

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

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

Posted

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,

Dream as if you'll live forever, live as if you'll die today
  • 4 weeks later...
Posted

also put myconnection.open() before mycommand.

 

You are trying to send a command to a database that isn't open yet.

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted
i haven't yet try using myCommand.dispose but i do try to give permission for everyone in my database folder allowed write and modify and it's work. could it be the main problem actually?
Posted
I am not sure this is the problem or else the error message you had would be Access Denied, not file already in use.
Dream as if you'll live forever, live as if you'll die today
  • 5 years later...
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...