[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Could not use ''; file already in use

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
preethamonline
Asked:
preethamonline
  • 3
  • 2
1 Solution
 
David H.H.LeeCommented:
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
 
David H.H.LeeCommented:
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
 
preethamonlineAuthor Commented:
Thanks X com. I have added the IUSR_ account. Any otther ways to prevent this from occuring
0
 
David H.H.LeeCommented:
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
 
preethamonlineAuthor Commented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now