BEGIN TRANSACTION

?

if in the Do Loop if the Rollback run and it exit sub i have to call the END TRANSACTION or the rollback call the end transaction

DbConnMain.SQLExecute "BEGIN TRANSACTION"
Do
  
  SqlStr="update invoicehd set status='P' Where status='D' And invnum=" + Rs.Field("invnum").StringValue.Trim
  DbConnMain.SQLExecute(SqlStr)
  If DbConnMain.Error Then
    DbConnMain.Rollback
    PayErr=True
    MsgBox "Error upDate Invoice Pay  " + DbConnMain.ErrorMessage
    Exit Sub
  Else
    PayErr=False
  End If
  
  If PayErr=False Then
    SqlStr="update paysinv Set status='Y' Where invnum=" + Rs.Field("invnum").StringValue.Trim + " And  storenum=" + Str(StoreNum)
    DbConn.SQLExecute(SqlStr)
    If DbConn.Error Then
      DbConn.Rollback
      MsgBox "Error update paysinv  " + DbConn.ErrorMessage
      Exit Sub
    End If
    
  End If
  
  Rs.MoveNext
Loop until Rs.EOF=True

DbConnMain.SQLExecute "END TRANSACTION"

Rollback cancels the transaction. A subsequent End Transaction should be an error.

Thanks