|
-
Apr 23rd, 2007, 04:30 AM
#1
Thread Starter
Frenzied Member
[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.
-
Apr 23rd, 2007, 08:14 AM
#2
PowerPoster
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]
-
Apr 23rd, 2007, 08:20 AM
#3
Thread Starter
Frenzied Member
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.
-
Apr 23rd, 2007, 09:51 AM
#4
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
-
Apr 23rd, 2007, 09:53 AM
#5
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|