given the following code:
Set conn = CreateObject("ADODB.Connection")
Set RS = CreateObject("ADODB.Recordset")
conn.BeginTrans
...
//This is the line it is about
RS.Open "SELECT a,b FROM c FOR UPDATE", conn, adOpenDynamic, adLockPessimistic
...
RS.Close
conn.CommitTrans
conn.Close
What is the difference when I use:
RS.Open "SELECT a,b FROM c (UPDLOCK)", conn, adOpenDynamic, adLockPessimistic
UPDATE:
Right now we use FOR UPDATE but it looks like the table is not locked. The SQL Profiler shows us this:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
declare @p1 int set @p1=NULL declare @p3 int set @p3=229378 declare @p4 int set @p4=163842 declare @p5 int set @p5=NULL exec sp_cursoropen @p1 output,N'SELECT a,b FROM c FOR UPDATE',@p3 output,@p4 output,@p5 output select @p1, @p3, @p4, @p5
UPDATE c SET a = a + 1 WHERE b = 'Value'
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
IF @@TRANCOUNT > 0 COMMIT TRAN
The update statement we use:
SQL = "UPDATE c SET a = a + 1 WHERE b= 'Value'"