Solved

Know if Record is lock

Posted on 2004-04-29
5
146 Views
Last Modified: 2010-05-02
I want to know if a record is used by other user, if it is then i want to disabled the save command button. I do this so that the user can only see the content but cannot save it if they have done some correction. The problem is that still other user can do some changes in the database since this code cannot determine that the record is used by others.
I dont know if this is the right way to do this but my code is:

if Adostinfo.LockType = adLockPessimistic then
        cmdSave.enable=false
else
        cmdSave.enable=true
end if

txtSName.text=adostinfo.recordset!stSName
txtFname.text=adostinfo.recordset!stFname

end sub

private sub cmdSave_click()
     adostinfo.recordset!stSName=txtSname.text
     adostinfo.recordset!stFname=txtFname.text
     adostinfo.recordset.update
     adostinfo.recordset.close
end sub

0
Comment
Question by:pedong
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 10949154
As best as I can discover there is no means of detecting a record's lock status via ADO.  You can implement such a system yourself by creating a parallel table to your data table and managing lock information yourself.  Here's an article that describes that approach.  It was written for Delphi but the concept translates ok.

http://www.howtodothings.com/showarticle.asp?article=210

I found another article that discusses pessimistic locking and ADO in an ASP environment.  Here too the environment is different (i.e. ASP versus pure VB) but the ADO concepts should be the same either way.

http://forums.aspfree.com/archive/t-5943

For whatever it's worth, according to Microsoft pessimistic locking only works if the you use a server side cursor.  A client side cursor uses optimistic locks even if pessimistic locking is set.  See these Microsoft articles:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;252317
http://support.microsoft.com/default.aspx?scid=kb;en-us;q189853
http://support.microsoft.com/default.aspx?scid=kb;en-us;190625&Product=ado

I don't know if this'll help but here's another Microsoft Article that deals with pessimistic locks.

http://support.microsoft.com/default.aspx?scid=kb;en-us;240317&Product=ado

And here's one that describes reading an Access LDB file.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;285822
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11977333
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept BlueDevilFan's comment as an answer

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

DarkoLord
EE Cleanup Volunteer
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question