Dear all,

I would like to make sure my concept of beginTrans and CommitTrans of ADODB.connection is correct, please comment on my question. Thanks in advance.

I have the following codes:

Code:
Public gConnect_Main As ADODB.Connection  'this is the connection object
Code:
  
Dim astrsql As String
Dim v_remark As String

gConnect_Main.BeginTrans

'assume the remark of ID="A1" has the original values = "lok"

astrsql = "update header set remark='lok1234' where ID='A1' "
gConnect_Main.Execute astrsql

astrsql = "select remark from header where ID='A1' "

v_remark = Fn_Select(gConnect_Main, astrsql)

Debug.Print v_remark

gConnect_Main.CommitTrans
Code:
Public Function Fn_Select(pConnect As ADODB.Connection, ByVal aSQLline As String) As Variant
On Error GoTo Err
Dim aRs As New ADODB.Recordset
If fn_SqlOpenRS(aRs, aSQLline, adCmdText, pConnect, adUseServer, adOpenForwardOnly) Then
    If Not aRs.EOF Then
        Fn_Select = IIf(IsNull(aRs.Fields(0).Value), 0, aRs.Fields(0).Value)
    End If
    Call fn_closeADOrs(aRs)
End If
Exit Function
Err:
    MsgBox Err.Description, vbCritical, Err.Source
    Fn_Select = 0
    Call fn_closeADOrs(aRs)
End Function
As far as I know, begintrans would only update the value if and only if committrans occurs. I would like to know, why "debug.print v_remark" prints the new value: "lok1234" ? I suppose this value is not yet updated in the database as commitTrans is not yet executed.

Is this related to the fact that in the function: "fn_Select" i use "adUseServer" and "adOpenForwardOnly"?