Results 1 to 8 of 8

Thread: record lock

  1. #1
    Join Date
    Nov 2003
    Location
    BANGALORE, INDIA
    Posts
    8

    Unanswered: record lock

    hi,

    using VB 6.0, sql server 7.0, ADO 2.5

    i will tell my requirement. i have a tran. window there i will select a chart number of a patient and do some changes and will go to next window for doing some other modification for the same patient, and again will go to other window. by this time don't allow other users to access the same patient chart number. should get a message like record locked by some other user.

    please help me to solve this issue

    prince

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    begin tran ???
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    Take a look at the begintrans/isolationlevel methods of the connection object and the locktype for the recordset object.

  4. #4
    Join Date
    Nov 2003
    Location
    BANGALORE, INDIA
    Posts
    8
    Originally posted by Enigma
    begin tran ???
    Dim recCase as new ADODB.Recordset
    Dim strSql as string

    strSql = "SELECT * FROM tblcase WHERE caseno = 'RAV000'
    recCase.Open strSql, g_clinicCon, adOpenDynamic, adLockPessimistic

    this is my code for displaying patient details.
    after displys the details in the corrp. text boxes i will close the recordset.

    but that particular record ie. 'RAV000' should lock from others access to access.

  5. #5
    Join Date
    Feb 2002
    Posts
    2,232
    Once you close the recordset, the lock(s) will no longer exist (there will still be a shared lock on the database but that will not prevent updates from occuring). Also, ado does not actually change the locking until you have referenced one of the fields in your sql select statement. That is why you have a begintrans/committrans/rollbacktrans methods for your connection object.

  6. #6
    Join Date
    Nov 2003
    Location
    BANGALORE, INDIA
    Posts
    8
    thanks

    is it possible to lock the record in backend. like exclucivelock.
    if it is possible in backend, i can write a stored procedure for lock the record and unlock also.
    will it work

  7. #7
    Join Date
    Feb 2002
    Posts
    2,232
    Yes, just treat is like a transaction - using:

    begin tran
    commit tran
    rollback tran

  8. #8
    Join Date
    Nov 2003
    Location
    BANGALORE, INDIA
    Posts
    8
    thanks for your help

    i try all the ways , but that is not sufficient for our case. thats why i implement a look table for locking table

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •