Results 1 to 5 of 5

Thread: [RESOLVED] Record locking

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Resolved [RESOLVED] Record locking

    Morning all.

    Quick question ....

    When updating or adding records into a table via VB, if I were to use

    Code:
    Sql = "update TABLEA set B = B + 1 where C = '1234'"
    connUpdate.Execute Sql
    rather than

    Code:
    Sql = "update TABLEA set B = B + 1 where C = '1234'"    
    Set rsUpdate = New ADODB.Recordset
    cmdUpdate.CommandText = Sql: cmdUpdate.ActiveConnection = connUpdate
    rsUpdate.Open cmdUpdate, , adOpenDynamic, adLockPessimistic
    Set rsUpdate = Nothing
    what are the benefits and/or pitfalls ?

    I realise that not defining a recordset for updates is neater, as its one less object to have to deal with, but how is locking handled in the first example ?
    Is it just determined by the server ?

    Apologies if all this sounds obvious, but I just don't know.
    Last edited by Hack; Apr 23rd, 2007 at 10:40 AM. Reason: Added RESOLVED to thread title Last edited by TheBionicOrange : Today at 10:54 AM.

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Record locking

    How about:

    [vbcode]
    connUpdate.Execute("update TABLEA set B = B + 1 where C = '1234'")\[/vbcode]
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  3. #3

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Record locking

    Well thats just a variation of the same thing.
    I'm using the first version, quite happily. I just wondered how any potential locking errors would be resolved thats all.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Record locking

    The database does the same thing whether you send it a recordset or not. Sending it a recordset, in command-type statements (update, insert, delete) gives the database extra work and increases traffic between the app and the database.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  5. #5

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Record locking

    Thanks ... thats kinda what I figured ... I just wasn't too sure so needed confirmation.

Posting Permissions

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



Click Here to Expand Forum to Full Width