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 :confused:
til now, i used the connection stringgCnnM.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 !!
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... ?
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
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.
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 !
Re: JET OLEDB & Access-MDB in multi-user environment
This could possibly give you some assistance - Database Problems and pay close attention to Concurrency
Re: JET OLEDB & Access-MDB in multi-user environment
nice, but no information, how to run a select-command without LOCK .. :confused:
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 ...
Re: JET OLEDB & Access-MDB in multi-user environment
:confused: can really no one give me a tip ????
Re: JET OLEDB & Access-MDB in multi-user environment
Selects don't produce locks if you don't ask them to...
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 ?
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.
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 ?
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.
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 ?
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