Thanks a lot for your suggestions
I try to replicate it closing connection but there's always an exception that's catched
It happens again recently, with same symptoms, in a different source, but this time there was an exception:
"System.InvalidOperationException:
ExecuteNonQuery: Connection property has not been initialized.
en System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
en System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
en System.Data.SqlClient.SqlCommand.ExecuteNonQuery() "
this exception was catched, in the catch block the method executes the tran.Rollback, but it still persisted data of the SP that uses begin tran ... commit tran
the exception happens when it tries to run this
Dim cmd2 As New SqlCommand("SET ARITHABORT ON", cn, tran)
cmd2.ExecuteNonQuery()
"cn" was initilialized from tran.Connection, at this point 5 SPs has been executed with the same tran instance, and before executing a 6th SP (that affects another tables on same DB) the "SET ARITHABORT ON" is executed
Now I would like to know what makes this Connection just dissappear and at same time why the tran.Rollback() doesn´t throw another exception
Dim cn As New SqlClient.SqlConnection("[valid connectionstring]")
cn.Open()
Try
... -- Lots of code, where in some function InvalidOperationException raises
tran.Commit()
catch as System.Exception
tran.Rollback()
throw
Finally
If not cn is nothing and also cn.state= ConnectionState.Open then
cn.Close()
End If
End Try
Any ideas?
Nemachtiani