mazlina Posted August 28, 2003 Posted August 28, 2003 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! Quote
*Experts* Bucky Posted August 28, 2003 *Experts* Posted August 28, 2003 Could we see the method that contains the line of code that causes this error? Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
mazlina Posted August 28, 2003 Author Posted August 28, 2003 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 Quote
Mehyar Posted August 28, 2003 Posted August 28, 2003 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, Quote Dream as if you'll live forever, live as if you'll die today
mazlina Posted September 25, 2003 Author Posted September 25, 2003 i've check the process aspnet_wp.exe and end that process. but it still didn't work.....is there any other possible error that i've done? Quote
techmanbd Posted September 25, 2003 Posted September 25, 2003 also need to dispose the command mycommand.dispose() Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
techmanbd Posted September 25, 2003 Posted September 25, 2003 also put myconnection.open() before mycommand. You are trying to send a command to a database that isn't open yet. Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
mazlina Posted September 25, 2003 Author Posted September 25, 2003 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? Quote
Mehyar Posted September 25, 2003 Posted September 25, 2003 I am not sure this is the problem or else the error message you had would be Access Denied, not file already in use. Quote Dream as if you'll live forever, live as if you'll die today
Krishnan Posted January 23, 2009 Posted January 23, 2009 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.