Solved

Know if Record is lock

Posted on 2004-04-29
5
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

717 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