Results 1 to 10 of 10

Thread: ADO.Net opens AccessDB always in exclusive mode ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19

    Question ADO.Net opens AccessDB always in exclusive mode ?

    Hi,

    i'm using vb.net with ado.net and asp.net:

    Scenario:
    ASP.Net creates an instance to the vb.net project and vb.net establishes the ado.net connection. But the AccessDB is always opened in exclusive mode ?

    this is my connection method in vb:

    Function dbopenread(ByVal osql As String) As OleDbDataReader
    odbpath = "C:\db\1.mdb"
    Dim objConn as New New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & odbpath & ";Jet OLEDBatabase Password=xxx")
    objConn.Open()
    Dim objCmd As New OleDbCommand(osql, objConn)
    Dim objDataReader As OleDbDataReader = objCmd.ExecuteReader
    objCmd.Dispose()
    objCmd = Nothing
    dbopenread = objDataReader
    End Function

    I also tried "Mode=SHARE DENY NONE" in the connection string?

    Any idea ?
    Thanks
    Oliver

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Are you getting specific error ?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    if i have opened the db exclusive in Access then i get an error with vb:
    An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll


    My thoughts are:
    if many users uses the pages at the same time and have a opened ado connection then ado tries to open the db again it creates perhaps an error ?

    thanks
    oliver

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Umm , I've just tried on Windows App (I don't know if it's different than Web App) . I open three instances of an app that uses a password-protected db . It seems to work fine . Are you sure the connectionstring is correct ? Look at the attached picture .
    Attached Images Attached Images  

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    i also tried it with a windows app. it's the same like you.

    But

    Scenario 1:
    you can open many different vb.net communications =>no prob

    Scanrio 2: Open before in Access exlusive mode the DB => you can't open a connection in VB.

    It's seems to be the normal way but curious. VB opens in exclusive mode (you can try a db operations in Access, which requires exclusive mode, for example DB compact and repair and Access tells you, it's already opened in exclusive mode) and can open several connections in exlusive mode too. But if you open in exclusive mode in Access you can't open it in VB ?!

    But because it seems normal => it's ok ?!

    Thanks
    Oliver

  6. #6
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256

    Re: ADO.Net opens AccessDB always in exclusive mode ?

    Originally posted by oma
    Hi,

    i'm using vb.net with ado.net and asp.net:

    Scenario:
    ASP.Net creates an instance to the vb.net project and vb.net establishes the ado.net connection. But the AccessDB is always opened in exclusive mode ?

    this is my connection method in vb:

    Function dbopenread(ByVal osql As String) As OleDbDataReader
    odbpath = "C:\db\1.mdb"
    Dim objConn as New New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & odbpath & ";Jet OLEDBatabase Password=xxx")
    objConn.Open()
    Dim objCmd As New OleDbCommand(osql, objConn)
    Dim objDataReader As OleDbDataReader = objCmd.ExecuteReader
    objCmd.Dispose()
    objCmd = Nothing
    dbopenread = objDataReader
    End Function

    I also tried "Mode=SHARE DENY NONE" in the connection string?

    Any idea ?
    Thanks
    Oliver
    Close your connection. objConn.Close()

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    @devgrp:
    connection is closed in another sub. So this makes no difference. You can try my described scenario with your vb source code and you will see, it opens in exclusive mode.

    it's a interesting logic => but seems to be normal

  8. #8
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Why is the connection being closed in another sub. After you read your data close the connection right there.

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by DevGrp
    Why is the connection being closed in another sub. After you read your data close the connection right there.
    I agree ,
    oma and how do you close the connection obj if it's dimmed within the function body . As I can see , it's out of scope .

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19
    @pirate

    i copied this function from a complex internet SAP solutions and changed for the posting some things. Normally the connection is dimmed outside.

    Oliver

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width