Solved

Could not use ''; file already in use

Posted on 2009-05-07
5
212 Views
Last Modified: 2012-05-06
Hi Guys! Am not sure if this is a comman problem using access. I want your opinion as to why this happens. And also could you Please check to see if i have used the right code for trapping the error. Thanks in advance.
Dim con As New System.Data.OleDb.OleDbConnection

        Dim myCommand As New System.Data.OleDb.OleDbCommand

        Dim myPath As String

        Dim MaxId As Integer
 

        myPath = Server.MapPath("hayat.mdb")

        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & myPath & ";"

        myCommand.CommandText = "select MAX(empid) from empdetails"

        myCommand.Connection = con

        Try

            con.Open()

            MaxId = myCommand.ExecuteScalar()

            lbllastid.Text = "The last Emp. ID stored is : " & MaxId.ToString

        Catch err As Exception

            lblmsg.Text = err.Message

        Finally

            con.Close()

        End Try

Open in new window

0
Comment
Question by:preethamonline
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
Hi preethamonline,
I didn't see any error here. The only things is you open access file during the application accessing the db.
You can't open it at the same time your application is connecting to this database.

0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
Comment Utility
Hi preethamonline,
Lastly, make sure you've granted enough permission for your application to access this database if the proposed not working.
Add IUSR_<COMPUTER_NAME> to the folder that the database resides.
0
 

Author Comment

by:preethamonline
Comment Utility
Thanks X com. I have added the IUSR_ account. Any otther ways to prevent this from occuring
0
 
LVL 29

Expert Comment

by:David H.H.Lee
Comment Utility
Hi preethamonline,
Does the problem resolved? If the proposed not solve the problem, that could be another possibilities for this causes.
Please provide more details for your current working environment setting for further inspection if need any further assistance.
0
 

Author Comment

by:preethamonline
Comment Utility
Hey Xcom. I'm no more getting the error. Sorry for the delay in posting. I was'nt feeling well for the past few days. Thanks a lot.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Contant UI messages in .NET 1 40
Put text in a picture ASP.NET C# 2 35
Paging GridView 7 32
JavaScript error 1 32
AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now