none
Can I open an Access database from vb .net if the mdb file is opened.

    Question

  • if I try to use the following connectstring

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\cse1\src\test.mdb;Mode=Share Deny None;User Id=admin;Password=;"


    I get the following error

    "The Microsoft Jet database engine cannot open the file 'test.mdb'. It is already opened exclusively by another user, or you need permission to view its data."

    I was assuming that mode-Share Deny None would open the database in read-only mode, since I have to just display data and not do any updates.

    thanks.

    Tuesday, August 02, 2005 6:19 PM

Answers

  • Yes you can open/read/write to an acces db when it is opened by another user (access is a multiuser DB),  However you can NOT when it is opened exclusively by another user...you may also want to make sure that you have access permission to that remote directory!
    Tuesday, August 02, 2005 7:31 PM
  • It's actually the other way round - double clicking an mdb file opens it in Exclusive mode so that no other application can access it, but while opening from with MsAccess, you have an option to say Open Read-Only or Open Exclusive Read-Only -with which the application continues to run fine, even if the mdb file is opened.

    But thanks for the clue.
    Wednesday, August 03, 2005 11:58 AM

  • Make sure that the read-only attribute is not set on the file.

    I will assume that the database is local and that the user has full access permissions to the folder where the file is located.

    In addition, You should be using OpenCurrentDatabase instead of OpenAccessProject. AFAIK, OpenAccessProject is for .adp files.

     

    Monday, October 09, 2006 8:51 PM

All replies

  • Yes you can open/read/write to an acces db when it is opened by another user (access is a multiuser DB),  However you can NOT when it is opened exclusively by another user...you may also want to make sure that you have access permission to that remote directory!
    Tuesday, August 02, 2005 7:31 PM
  • I can open it from within my vb .net application if another person is opening the same database using the same application (so mutiluser is workingfine)
    But when I manually open the mdb file - just double click on the mdb file and open it - I guess it opens it in Exclusive mode, is there any way that when I open the database from MsAccess I can open it such mode so that my application keeps running.

    thanks.
    Tuesday, August 02, 2005 8:21 PM
  • My experience has been that the .mdb can be opened exclusively when using the File, Open dialow within Access, but that that double-clicking in WinExplorer opens in shared mode.  This seems consistent with the command-line options for Access listed here .

    Garth
    Tuesday, August 02, 2005 9:17 PM
  • It's actually the other way round - double clicking an mdb file opens it in Exclusive mode so that no other application can access it, but while opening from with MsAccess, you have an option to say Open Read-Only or Open Exclusive Read-Only -with which the application continues to run fine, even if the mdb file is opened.

    But thanks for the clue.
    Wednesday, August 03, 2005 11:58 AM
  • Hi I seem to have the same problem as yours. I am using MS Access and ASP.NET (C#) in project, when I test my application with two users executing same query from two different computers, I get the following error.

    " can not open any more databases"

    Do you have any idea, why this problem occurs?

    Since these are only executing queries and no update operation is performed in Access I tried giving Shared Deny as you said, but still the same error persists. When two persons try to execute a query at same time, for the fisrt person who requested gets the currect answer, where as the other not, instead he gets the same error as I mentioned above.

    Please help me..

    Thanks

    Sony Sebastian

    Friday, May 19, 2006 4:49 AM
  • make sure that you have "Mode=Share Deny None" in your connectstring.
    Thursday, August 24, 2006 5:06 PM
  • Yes

    reference com ado 2.8 component

    Try

    "Provider=Microsoft.jet.4.0;Data source=\\cse1\src\test.mdb;Persist Security Info=False"

    • Proposed as answer by Bruce Tompkins Friday, November 25, 2011 10:29 PM
    Tuesday, August 29, 2006 12:36 AM
  • I have been importing excel worksheets into different excel workbooks.  I have constantly struggled with the ability to edit those worksheets that I am pulling into other workbooks, while one of the workbooks that imports the sheet is open.

    With the combination of adding the "Persist Security Info=False" and "Mode=Share Deny None" I have been able to accomplish this.  Hopefully this will help somone who has the same problem as me in the future as this took me a long time to figure out.

    I needed to add the clauses to the actual connection string on my computer before importing the data into excel.

    Tuesday, September 05, 2006 2:25 PM
  • Hi, I am trying the same thing and sort of having the same problem and I am new to this.  I am trying to open up an Access database through VB.NET then run a macro (already defined within Access) on the database. This code runs into an error on the line I have highlighted red below.  At this point I can either break or continue. Both of which result in the program ending.   

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Me.CenterToScreen()

    Dim myAccess As New Access.Application

    Dim allMacro As String = "Macros"

    myAccess = CreateObject("Access.Application")

    myAccess.Visible = True

    myAccess.OpenAccessProject("c:\path\databaseName.mdb")

    myAccess.DoCmd.RunMacro(allMacro)

    End Sub

    I am getting the error

    An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WindowsApplication1.exe

    Additional information: Microsoft Office Access can't open the database because it is missing, or opened exclusively by another user.

    Any kind of nudge in the right direction, somthing I should read, example code, or somone telling me where I am going wrong would be much appreciated.

    Thankyou!

    Monday, October 09, 2006 4:20 PM

  • Make sure that the read-only attribute is not set on the file.

    I will assume that the database is local and that the user has full access permissions to the folder where the file is located.

    In addition, You should be using OpenCurrentDatabase instead of OpenAccessProject. AFAIK, OpenAccessProject is for .adp files.

     

    Monday, October 09, 2006 8:51 PM
  • wow thanks that was my problem! :)
    Tuesday, October 10, 2006 8:58 PM
  • Did you add a reference to Microsoft Access 11.0 object library? I'm trying to do the same thing as you. Currently i'm running into securityerrors.
    Thursday, March 01, 2007 8:44 AM