
RDO Problem when rolling back transaction - Function sequence error
HI
I am getting the following error message when I try and rollback a
transaction within an rdoConnection:
40002:S1010:[Microsoft]:[ODBC SQL?Server Driver]:Function sequence error
The transaction is getting rolled back no problem but I get the annoying
error message and then the function terminates. Below is a listing of the
code that is causing the problem. Any advice appreciated.
Other Details:
SQLSRV32.dll Version 2.65.0201
VB4.0a Enterprise Edition
RDO1.0b
WinNT 4.0
James Eyre
(VBA Software Pty Ltd
Function AddSpec(cnSQL as rdoConnection) as long
Dim bInTrans As Boolean
Dim lNewSpec As Long
Dim iParts As Integer
On Error GoTo Err_AddSpec
bInTrans = False
AddSpec = 0
If ValidDetails Then
cnSQL.BeginTrans
bInTrans = True
'Add the spec to the tblParts table
Set rdoPS = cnSQL.rdoPreparedStatements!AddSpec
With rdoPS
.rdoParameters(0).Direction = rdParamOutput
.rdoParameters(1) = specNum
.rdoParameters(2) = specDesc
.rdoParameters(3) = specType
If specLocation = 0 Then
.rdoParameters(4) = Null
Else
.rdoParameters(4) = specLocation
End If
.rdoParameters(5) = specClass
.rdoParameters(6) = cvSuppId
End With
rdoPS.Execute
lNewSpec = rdoPS.rdoParameters(0)
'Add the spec details to the tblSpecDetails table
Set rdoPS = cnSQL.rdoPreparedStatements!AddSpecDets
With rdoPS
.rdoParameters(0) = lNewSpec
.rdoParameters(1) = specCust
.rdoParameters(2) = specSoftware
.rdoParameters(3) = specDets
.rdoParameters(4) = specDesc
End With
rdoPS.Execute
'Add the spec parts to the tblSpecParts table
Set rdoPS = cnSQL.rdoPreparedStatements!AddSpecParts
For iParts = 1 To specParts.Count
With rdoPS
.rdoParameters(0) = lNewSpec
.rdoParameters(1) = specParts(iParts).prtId
.rdoParameters(2) = specParts(iParts).prtQty
End With
rdoPS.Execute
Next iParts
Goto Err_AddSpec <= To force the operation to Rollback
cnSQL.CommitTrans
AddSpec = lNewSpec
bInTrans = False
End If
Exit_AddSpec:
Exit Function
Err_AddSpec:
On Error GoTo 0
If bInTrans = True Then
cnSQL.RollbackTrans => This causes the error message listed above
and exits the function
End If
Err.Raise vbObjectError + 1003
Resume Exit_AddSpec
End Function