access locks

  • hii

    could anyone tell me how to lock records in access and how to remove them.

    Thank u

  • If it is MDB Access will create a file with an extention LDB. If a lock does not go away, deleting this file will remove the lock.

  • Can you let me know the requirement... why you want to lock records.

    You can use the sp : sp_getapplock to lock records

    for more info visit the link :

    http://msdn.microsoft.com/en-us/library/aa933410(SQL.80).aspx

    If you lock any record or table you should release the lock.

    You need to use sp_releaseapplock to release the lock.

    Both should be in a transaction.

    You can run the sp_getapplock within a transcation.

    I hope it will help you.

    Do you want to generate any id.. or serial no by locking the table?

  • Kolivad,

    I went to the link, and it looks the solution applies to SQL 2000. Do you have a comparitive solution for Access db?

    Gouthama Kolivad (12/2/2008)


    for more info visit the link :

    http://msdn.microsoft.com/en-us/library/aa933410(SQL.80).aspx

    If you lock any record or table you should release the lock.

    You need to use sp_releaseapplock to release the lock.

  • I dont have much experience in Access DB.....

    Since it is a Database.. it should have locking facilities.

    What I can suggest you is that ... if you are generating your own id.... you want to avoid concurrency... you can write some function which is used to generate the id.. you can call the function while inserting ...

    The insert statement would look like...

    Insert into tableA (id, name, address)

    values(gen_id(), 'test','testaddress')

    Here gen_id() is the function which is used to generate the id i.e. may be next sequence number.

    This would definitely avoid concurrency.. since while inserting a record no other insertions are possible... i.e concurrent insert is not possible.

    But the other user can read at the same time.

    Do you want to avoid concurrent read also?

    If so in sql server we use tablock to lock table so that no other read/write is possible at the same time. But I dont know the solution for access. Sorry to say this. But I think there should be some way. Just search on the net to get some idea.

  • Um, actually I was interested in unlocking a locked .mdb file. (See Perry Harts post above).

    But with respect to your information, do you know if there is any code to write in VB, VBA, or any other "object-oriented" way", to implement the unlocking of an .mdb? (All my attempts to unlock the .mdb using Access and the command-line have failed)....

    ....which brings me to a side-question....is there a way to write VB directly at a command prompt in Windows XP to work with Access DB objects, and NOT have to open Access up directly????

    Once again, thanks for your response. I will def. be returning back to your observation to implement your suggestion on something else, I'm sure. 🙂

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply