July 22, 2002 at 7:43 am
Here is my vb.net code, this code is in an .aspx page.
Dim objDbConn As New SqlConnection(ConfigurationSettings.AppSettings("strConnEnterprise"))
objDbConn.Open()
Dim objCommand As New SqlCommand()
Dim objTransaction As SqlTransaction
objCommand.Connection = objDbConn
objTransaction = objDbConn.BeginTransaction
objCommand.Transaction = objTransaction
strSQL = "CREATE TABLE Prova (OID int IDENTITY(1, 1) PRIMARY KEY CLUSTERED, OID_tbBaseProducts int NOT NULL REFERENCES tbBaseProducts(OID))"
objCommand.CommandText = strSQL
Dim s As Integer
Try
s = objCommand.ExecuteNonQuery()
objTransaction.Commit()
Catch ex As SqlException
objTransaction.Rollback()
Finally
objDbConn.Close()
End Try
If table Prova exists in my SQL-server archive transaction's roolback raise an exception :
"The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION"
but BEGIN TRANSACTION exists in my code.
What's the solution of the problem ?
Thank's anakin
July 24, 2002 at 3:00 am
Hi, put the begin transaction in the try block.
regards,
Klaas-Jan
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply