Transactions commit during command timeout
From: Mike Vedder (mikevedder_at_online.nospam)
Date: 12/22/04
- Next message: ctech: "mdac 2.8 rolls back at end of installation"
- Previous message: SK: "Re: Rename column"
- Next in thread: Kevin Yu [MSFT]: "RE: Transactions commit during command timeout"
- Reply: Kevin Yu [MSFT]: "RE: Transactions commit during command timeout"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 22 Dec 2004 09:03:05 -0800
I have a VB.NET application that calls VB6 DLL. The DLL calls a SQL stored
procedure. The stored procedure executes a few INSERT statements, which are
surrounded by a 'Begin tran' and 'Commit'.
Here is the relevant VB6 DLL code:
Public Function RunSPReturnInteger(ByVal StoredProcName As String, _
ByVal ReturnParamName As String, _
ParamArray params() As Variant) As Variant
Dim DataConn As ADODB.Connection
Dim Cmd As ADODB.Command
Dim AttemptCount As Integer
Dim Error As ADODB.Error
Dim ErrorString As String
On Error GoTo ErrorHandler
10 Set Cmd = New ADODB.Command
20 Set DataConn = OpenDataConnection()
30 With Cmd
40 Set .ActiveConnection = DataConn
50 .CommandText = StoredProcName
60 .CommandType = adCmdStoredProc
70 .CommandTimeout = CommandTimeout
End With
'the following routine adds the params to the cmd object
80 collectParams Cmd, params
' Execute without a resulting recordset and
'pull out the "return value" parameter
90 Cmd.Execute , , ADODB.adExecuteNoRecords
100 RunSPReturnInteger = Cmd.Parameters(ReturnParamName).Value
' Cleanup and return
110 DataConn.Close
120 Set DataConn = Nothing
130 Set Cmd = Nothing
Exit Function
ErrorHandler: 'removed for this post
End Function
The following error occasionally gets raised on line 90:
Number(-2147217871)
Source(Microsoft OLE DB Provider for SQL Server)
SQLState(HYT00)
Description(Timeout expired)
However, about half the time that the error is raised, I find that the
transaction in the stored procedure is committed. My program has no way of
knowing the records were inserted.
My main question is: Why does the transaction get committed on a timeout,
and how can I prevent this?
(I would post the stored procedure code, but it is rather lengthy. I should
note that the stored procedure does not have a 'rollback tran' command. Is
this necessary? Does a timeout need to be explicitly checked for in a stored
procedure and then the rollback command called?)
We are using SQL2000, MDAC 2.8, and .NET 1.1 SP1
The stored procedure gets called about 10,000 times a day. The timeouts
have averaged about 70 per month with the transaction being committed about a
third of that. The timeouts usually occur in bursts (i.e. we might have 20
at once, when there is a problem on the network).
Thanks,
Any help is appreciated.
- Next message: ctech: "mdac 2.8 rolls back at end of installation"
- Previous message: SK: "Re: Rename column"
- Next in thread: Kevin Yu [MSFT]: "RE: Transactions commit during command timeout"
- Reply: Kevin Yu [MSFT]: "RE: Transactions commit during command timeout"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|