|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Locking a record in Access from vb.netHi all,
I need to lock a record while a user edits that record, so other users see a "Record is locked" message when try to access that specific record. I know there is a lockrecord property in Access, but I'm not sure how to lock this record from my vb.net form. Any help would be highly appreciated. Roy Roy,
That is something expressely not implemented in the non connected environment as AdoNet is. To get the idea, think for that how you would do that in a PDA which has no mobile connection. For that is ADONET as well. AdoNet is mainly build arround optimistic concurrency. The thought behind the last is that proven is that seldom a conncurrency error exist and that those can better than be corrected afterwards by telling the user that he has to do things he did again. Or whatever method you want to use for that. I hope this helps, Cor Show quote "Roy" <R**@discussions.microsoft.com> schreef in bericht news:B2B7CB77-92C1-442E-BAC6-D7B32F3E02D9@microsoft.com... > Hi all, > > I need to lock a record while a user edits that record, so other users see > a > "Record is locked" message when try to access that specific record. I know > there is a lockrecord property in Access, but I'm not sure how to lock > this > record from my vb.net form. > Any help would be highly appreciated. > > Roy Thanks Cor for your response, but I need to find a way to do this. Do you
have any suggestions? Roy Show quote "Cor Ligthert [MVP]" wrote: > Roy, > > That is something expressely not implemented in the non connected > environment as AdoNet is. > > To get the idea, think for that how you would do that in a PDA which has no > mobile connection. For that is ADONET as well. > > AdoNet is mainly build arround optimistic concurrency. The thought behind > the last is that proven is that seldom a conncurrency error exist and that > those can better than be corrected afterwards by telling the user that he > has to do things he did again. Or whatever method you want to use for that. > > I hope this helps, > > Cor > > "Roy" <R**@discussions.microsoft.com> schreef in bericht > news:B2B7CB77-92C1-442E-BAC6-D7B32F3E02D9@microsoft.com... > > Hi all, > > > > I need to lock a record while a user edits that record, so other users see > > a > > "Record is locked" message when try to access that specific record. I know > > there is a lockrecord property in Access, but I'm not sure how to lock > > this > > record from my vb.net form. > > Any help would be highly appreciated. > > > > Roy > > > Roy,
> Thanks Cor for your response, but I need to find a way to do this. Do you Not really you can look on MSDN for pesimistic and optimistic concurrency. > have any suggestions? > Roy > However the last time I searched for that was the information in fact only about optimistic concurrency. If you want to search on Google use than ADONET pesimistic concurrency http://www.google.com/search?hl=en&q=ADONET+pesimistic+concurrency&btnG=Google+Search I hope this helps a little Cor Roy,
You might try using a transaction. But really, ADO.Net is not the tool to use if you need pessimistic locking. If I absolutely needed this kind of functionality I would use classic ADO. Kerry Moorman Show quote "Roy" wrote: > Thanks Cor for your response, but I need to find a way to do this. Do you > have any suggestions? > Roy > > "Cor Ligthert [MVP]" wrote: > > > Roy, > > > > That is something expressely not implemented in the non connected > > environment as AdoNet is. > > > > To get the idea, think for that how you would do that in a PDA which has no > > mobile connection. For that is ADONET as well. > > > > AdoNet is mainly build arround optimistic concurrency. The thought behind > > the last is that proven is that seldom a conncurrency error exist and that > > those can better than be corrected afterwards by telling the user that he > > has to do things he did again. Or whatever method you want to use for that. > > > > I hope this helps, > > > > Cor > > > > "Roy" <R**@discussions.microsoft.com> schreef in bericht > > news:B2B7CB77-92C1-442E-BAC6-D7B32F3E02D9@microsoft.com... > > > Hi all, > > > > > > I need to lock a record while a user edits that record, so other users see > > > a > > > "Record is locked" message when try to access that specific record. I know > > > there is a lockrecord property in Access, but I'm not sure how to lock > > > this > > > record from my vb.net form. > > > Any help would be highly appreciated. > > > > > > Roy > > > > > > Thanks Kerry,
Would you explain how to use classic ADO? I tried rs.Open and defined adLock Pessimistic as lock type, but it cannot lock the record and another user can update that record. Roy Show quote "Kerry Moorman" wrote: > Roy, > > You might try using a transaction. > > But really, ADO.Net is not the tool to use if you need pessimistic locking. > > If I absolutely needed this kind of functionality I would use classic ADO. > > Kerry Moorman > > > "Roy" wrote: > > > Thanks Cor for your response, but I need to find a way to do this. Do you > > have any suggestions? > > Roy > > > > "Cor Ligthert [MVP]" wrote: > > > > > Roy, > > > > > > That is something expressely not implemented in the non connected > > > environment as AdoNet is. > > > > > > To get the idea, think for that how you would do that in a PDA which has no > > > mobile connection. For that is ADONET as well. > > > > > > AdoNet is mainly build arround optimistic concurrency. The thought behind > > > the last is that proven is that seldom a conncurrency error exist and that > > > those can better than be corrected afterwards by telling the user that he > > > has to do things he did again. Or whatever method you want to use for that. > > > > > > I hope this helps, > > > > > > Cor > > > > > > "Roy" <R**@discussions.microsoft.com> schreef in bericht > > > news:B2B7CB77-92C1-442E-BAC6-D7B32F3E02D9@microsoft.com... > > > > Hi all, > > > > > > > > I need to lock a record while a user edits that record, so other users see > > > > a > > > > "Record is locked" message when try to access that specific record. I know > > > > there is a lockrecord property in Access, but I'm not sure how to lock > > > > this > > > > record from my vb.net form. > > > > Any help would be highly appreciated. > > > > > > > > Roy > > > > > > > > > Roy,
I haven't used classic ADO in a while. But if I recall correctly, you first must set some recordset properties to appropriate values: CursorType = adOpenKeyset LockType = adLockPessimistic CursorLocation = adUseServer Then, when the record is placed into Edit mode, the lock is applied. It seems to me that to place the record into Edit mode you need to assign a new value to one of its fields. So if you want to place the record into Edit mode as soon as you have retrieved it, you need to assign some new value to one of its fields immedieately. There may be an explicit Edit mode that you can place the record into, but I can't remember it. Kerry Moorman Show quote "Roy" wrote: > Thanks Kerry, > > Would you explain how to use classic ADO? I tried rs.Open and defined adLock > Pessimistic as lock type, but it cannot lock the record and another user can > update that record. > > Roy > > "Kerry Moorman" wrote: > > > Roy, > > > > You might try using a transaction. > > > > But really, ADO.Net is not the tool to use if you need pessimistic locking. > > > > If I absolutely needed this kind of functionality I would use classic ADO. > > > > Kerry Moorman > > > > > > "Roy" wrote: > > > > > Thanks Cor for your response, but I need to find a way to do this. Do you > > > have any suggestions? > > > Roy > > > > > > "Cor Ligthert [MVP]" wrote: > > > > > > > Roy, > > > > > > > > That is something expressely not implemented in the non connected > > > > environment as AdoNet is. > > > > > > > > To get the idea, think for that how you would do that in a PDA which has no > > > > mobile connection. For that is ADONET as well. > > > > > > > > AdoNet is mainly build arround optimistic concurrency. The thought behind > > > > the last is that proven is that seldom a conncurrency error exist and that > > > > those can better than be corrected afterwards by telling the user that he > > > > has to do things he did again. Or whatever method you want to use for that. > > > > > > > > I hope this helps, > > > > > > > > Cor > > > > > > > > "Roy" <R**@discussions.microsoft.com> schreef in bericht > > > > news:B2B7CB77-92C1-442E-BAC6-D7B32F3E02D9@microsoft.com... > > > > > Hi all, > > > > > > > > > > I need to lock a record while a user edits that record, so other users see > > > > > a > > > > > "Record is locked" message when try to access that specific record. I know > > > > > there is a lockrecord property in Access, but I'm not sure how to lock > > > > > this > > > > > record from my vb.net form. > > > > > Any help would be highly appreciated. > > > > > > > > > > Roy > > > > > > > > > > > > On Fri, 3 Mar 2006 07:11:26 -0800, Roy <R**@discussions.microsoft.com> wrote:
¤ Thanks Kerry, ¤ ¤ Would you explain how to use classic ADO? I tried rs.Open and defined adLock ¤ Pessimistic as lock type, but it cannot lock the record and another user can ¤ update that record. ¤ ¤ Roy ¤ You need to keep in mind that there is a difference between page level and row level locking in Access. See the following: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeopg/html/deovrpagelevellockingvsrecordlevellocking.asp Paul ~~~~ Microsoft MVP (Visual Basic) On Thu, 2 Mar 2006 07:27:54 -0800, Roy <R**@discussions.microsoft.com> wrote:
¤ Thanks Cor for your response, but I need to find a way to do this. Do you ¤ have any suggestions? ¤ Roy ¤ What you could do is use a semaphore or update counter column in your table for each row to indicate when a row is being updated. Just make certain that you understand that a user can potentially lock a row indefinitely. Your application may have to track how long a row is in edit mode if you want to avoid this situation. Alternatives for pessimistic locking, if you are looking for a built-in method when working with an Access database, would require using a connected data access mechanism such as DAO or ADO. Paul ~~~~ Microsoft MVP (Visual Basic) Thank you all.
Show quote "Roy" wrote: > Thanks Cor for your response, but I need to find a way to do this. Do you > have any suggestions? > Roy > > "Cor Ligthert [MVP]" wrote: > > > Roy, > > > > That is something expressely not implemented in the non connected > > environment as AdoNet is. > > > > To get the idea, think for that how you would do that in a PDA which has no > > mobile connection. For that is ADONET as well. > > > > AdoNet is mainly build arround optimistic concurrency. The thought behind > > the last is that proven is that seldom a conncurrency error exist and that > > those can better than be corrected afterwards by telling the user that he > > has to do things he did again. Or whatever method you want to use for that. > > > > I hope this helps, > > > > Cor > > > > "Roy" <R**@discussions.microsoft.com> schreef in bericht > > news:B2B7CB77-92C1-442E-BAC6-D7B32F3E02D9@microsoft.com... > > > Hi all, > > > > > > I need to lock a record while a user edits that record, so other users see > > > a > > > "Record is locked" message when try to access that specific record. I know > > > there is a lockrecord property in Access, but I'm not sure how to lock > > > this > > > record from my vb.net form. > > > Any help would be highly appreciated. > > > > > > Roy > > > > > > |
|||||||||||||||||||||||