Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LockTypeEnum Enumeration (DAO) 2

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

I'm developing a new app and trying to move away from bound controls and use a recordset instead via MVC.

In my Model I have a recordset record and was wondering on the best 'fetch' options to use to ensure while the '.edit' & '.update' is being performed , the record is correctly locked.

I am considering using
Code:
, dbOpenDynaset, dbSeeChanges, dbOptimistic

Are these the correct Enum types to use for this?

Thanks,
1DMF

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
Hi Maj,

Thanks for the list, though a little confused by it.

It states Dynaset for EditMode / Updateable is RO (Read Only) ?

I'm currently using a dynaset recordset already to add new records via
Code:
Dim rs As DAO.Recordset
Set rs = Currentdb.OpenRecordset("SELECT RECID,x,z,y FROM table WHERE RECID = 0", dbOpenDynaset, dbSeeChanges)
rs.AddNew
rs.Fields("x") = someValue;
rs.Fields("y") = someValue;
rs.Fields("z") = someValue;
rs.Update

Where I know no record ever has a RECID = 0 , so creates an empty recordset ready for adding a new record, I then set the values of the columns I require and the update then inserts the new record into the table, and it is working fine.

I must be reading the list wrong, can you elaborate please.

Thanks,
1DMF.




"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
I think you might be confused on the editmode property. That is a great article see table 8-7 for a detailed discussion on the editmode property.
 
Yeah, Thanks Maj!

I read that as in 'edit mode' the record is Read Only, not that 'EditMode' is a read only property!

Finaly found the bit I was interested in
LockEdits
--------------------------------------------------------------------------------

Data Type

Boolean

Description

For updatable recordsets the LockEdits property sets or returns a value indicating the type of locking in effect while editing, as shown in Table 8-8. Pessimistic locking (True) means that the page containing the record being edited is unavailable to other users until you are through editing and use the Update method to save the record. Optimistic locking (False) means that other users can access the same record you are working on, except just briefly while you are actually updating the record. Optimistic locking is more risky (two users can simultaneously change a record), but pessimistic locking may cause delays while records are unnecessarily locked.

Table 8-8: The LockEdits Values/Settings Named Constant
Value
Description

True
-1
(Default) Pessimistic locking is in effect. The 2K page containing the record you're editing is locked as soon as you call the Edit method.

False
0
Optimistic locking is in effect for editing. The 2K page containing the record is not locked until the Update method is executed.


TIP:

The LockEdits value can be preset by setting the lockedit argument of the OpenRecordset method; setting the lockedit argument to dbPessimistic sets the LockEdits property to True, and setting it to any other value sets LockEdits to False. When working with ODBC data sources, LockEdits is always set to False, allowing only optimistic locking.

Much obliged.

So from this statement
Optimistic locking is more risky (two users can simultaneously change a record), but pessimistic locking may cause delays while records are unnecessarily locked.
would you use pessimistic just to be on the safe side?

1DMF


"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
would you use pessimistic just to be on the safe side?
Yes, as I don't want 2 users updating the same row at the same time.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top