Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217

    Unanswered: ADO - locking recordset

    With ADO, how can you lock a certain recordset so that nobody else could read or edit it ?

    Please note that I said "nobody else could READ or EDIT it", so only my program can read or edit it.

    e.g.

    rs.open "Select * from Orders where CustomerID=50", .......

  2. #2
    Join Date
    Mar 2005
    Posts
    22
    Use the adLockPessimistic lock type. adLockPessimistic—which is the most stringent lock type available—will lock the record from the time editing begins until an Update or MoveNext method is called. Make sure that your Recordset Open method specifies the adCmdTableDirect option and that the cursor type is set to adOpenStatic or adOpenDynamic. They will still be able to read the data but not see the updates until you release the record.

  3. #3
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217

    not even read

    No, no. I want nobody else could READ it.
    Not even to read it.

    Any ideas ? Thanks.

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Nobody can read or edit your recordset ... That is something only in your program ... Now, are you really talking about a TABLE or QUERY????
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    M Owen correctly indicated that the RECORDSET is ONLY accessable from within your app.

    The table row, however, CANNOT be locked so that records are not readable.

    As a possible workaround, IF all the clients are the same, you could add an edit status field to the table, update this field when you begin editing a record, and clear the status field when you are done editing (before you release the record) Personally, I would make this status flag actually contain the user name of the user who is editing the record (more later) and be null if no-one is editing the record.

    In your app, add code so the record will not be opened unless the flag is null.

    However, the drawback is this: IF your app crashes while you're editing a record, this will leave the record in a "locked" state. This is why I recommend using a user name as the current record "owner." That way, when there's a question as to why a given record is locked, you know who to talk to.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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