Results 1 to 15 of 15

Thread: JET OLEDB & Access-MDB in multi-user environment

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    JET OLEDB & Access-MDB in multi-user environment

    i have a MDB in a multi-user-environment (5 user) and use OLEDB to manipulate data.

    in some situations (unpredictable), a user gets a
    3218 ("Update not possible, currently locked")
    from the JET-Engine when executing e.g. an INSERT-command

    til now, i used the connection string
    gCnnM.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DataBase & ";"
    without further settings.

    could it be, that there is a default of "Page-Level Locking" for the property Jet OLEDB : Database Locking Mode ?

    or has anyone an idea, where my problem could be ?

    generally: where can i find the default values for the ADO-properties when connecting to an Access-Databse ?

    THX for help !!

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: JET OLEDB & Access-MDB in multi-user environment

    Generally when a record is being entered/editted it used to lock 2kb on either side of the record. If you built the db to be bound then when you edit this may happen.

    If you use inserts and there is no bound editting, its just bad luck. In which case catch the error, and try it again after 2 seconds. If that failas ask the user... ?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    Re: JET OLEDB & Access-MDB in multi-user environment

    Quote Originally Posted by Ecniv
    ... If you built the db to be bound then when you edit this may happen.

    If you use inserts and there is no bound editting, its just bad luck. In which case catch the error, and try it again after 2 seconds. If that failas ask the user... ?
    wow, thank u for quick reply ... but i am confused...
    what does "built the db to be bound" mean ??
    it is a "normal" mdb-file containing tables (and only tables)

    is catching the error and retry it after a while the only way to avoid such situations ?

    sigi

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: JET OLEDB & Access-MDB in multi-user environment

    Does someone have a record set open? What is the mode of the recordset? When you open a recordset in Access the database will lock that record so that only the person having the record open first can edit it (this prevents some from over writing changes you make). What Access does is something called page locking (instead of record locking). A page lock will lock any record that exsists in the same 2K block as the record you are working on. So if the record is less then 2K in length you might be locking 2 or more records at the same time. If the recordset was opened as open table you might actually be locking the full table from any insert,update or delete from anyone but that person who opens the table first.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    Resolved Re: JET OLEDB & Access-MDB in multi-user environment

    i use the follwoing code for READING and filling data into a datatable:
    (up to max 500 records)

    Code:
              Dim cmD As System.Data.OleDb.OleDbCommand
                Dim cdR As System.Data.OleDb.OleDbDataReader
                Dim xSQL As String
    
                xSQL = "SELECT " & gSQLlimit & " * FROM ADRESSE " 
                cmD = New System.Data.OleDb.OleDbCommand(xSQL, gCnn)
                cdR = cmD.ExecuteReader
                While cdR.Read
                            ' **** fill data into datatable
                End While
                cdR.Close()
    for all other functions (INSERT, UPDATE, DELETE) - i use code like this (creating an SQL-string and executing with .ExecuteNonQuery
    Code:
            Dim cmD As System.Data.OleDb.OleDbCommand
            Dim xSQL as String
            On Error GoTo DErr
            xSQL = "DELETE FROM ADRESSE WHERE ADadnr = " & mADRESSE.ADadnr
            cmD = New System.Data.OleDb.OleDbCommand(xSQL, gCnn)
            cmD.ExecuteNonQuery()
    so i think, a user has only for a very short moment an open recordset.

    there is no need of locking when i use the recordset - how could i turn off locking ???

    THANK YOU !

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: JET OLEDB & Access-MDB in multi-user environment

    This could possibly give you some assistance - Database Problems and pay close attention to Concurrency

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    Re: JET OLEDB & Access-MDB in multi-user environment

    nice, but no information, how to run a select-command without LOCK ..
    my program should work exaktly like described in the article above -
    but to achieve this, i should be able to run a .ExecuteReader-Command
    without producing a lock ...

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    Re: JET OLEDB & Access-MDB in multi-user environment

    can really no one give me a tip ????

  9. #9
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: JET OLEDB & Access-MDB in multi-user environment

    Selects don't produce locks if you don't ask them to...

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    Re: JET OLEDB & Access-MDB in multi-user environment

    but from where could my lock-situation come ?
    all INSERT/UPDATE/DELETE refer to one single ROW ?

  11. #11
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: JET OLEDB & Access-MDB in multi-user environment

    Are you opening the select recordset with a forward only (ReadOnly) Cursor? That would solve your problem.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    Re: JET OLEDB & Access-MDB in multi-user environment

    no, not so far as i know - pls look at the code i posted in this thread.
    how can i set this option ?

  13. #13
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: JET OLEDB & Access-MDB in multi-user environment

    Sorry, I don't use .NET but the process is still the same. You MUST indicate to use a different type of cursor than the default. The default cursor is not always the correct cursor to use especially in a multi-user environment.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Nov 2006
    Location
    Austria
    Posts
    109

    Re: JET OLEDB & Access-MDB in multi-user environment

    Quote Originally Posted by randem
    Sorry, I don't use .NET but the process is still the same. You MUST indicate to use a different type of cursor than the default. The default cursor is not always the correct cursor to use especially in a multi-user environment.
    perhaps you could show me, how YOU do that ? (.net or not) -
    then i could transform it to my need ?

  15. #15
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: JET OLEDB & Access-MDB in multi-user environment

    Code:
        snpTable.Open SQL, RSD.dbCurrent, adOpenStatic, adLockReadOnly, adCmdText
    
        snpTable.Open SQL, RSD.dbCurrent, adOpenForwardOnly, adLockReadOnly, adCmdText

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