S
Shawn
Hi. I'm calling a procedure that inserts a new record in my oracle DB. I'm
using an OleDbTransaction object so that if anything goes wrong the
transaction is not commited and the new record is not inserted. The problem
is that the transaction is carried out regardless of the commit method is
called or not. This code for instance even has a RollBack, but it still
inserts the new record. Can somebody please tell me what I'm doing wrong?
Dim oleDbConnection As OleDbConnection
Dim strOleDbConnectionString As String = _
"Provider=OraOLEDB.Oracle;" & _
"Data Source=xxx;" & _
"User Id=xxx;" & _
"Password=xxxx"
oleDbConnection = New OleDbConnection(strOleDbConnectionString)
oleDbConnection.Open()
Dim oleDbCommand As OleDbCommand
oleDbCommand = New OleDbCommand()
oleDbCommand.Connection = oleDbConnection
OleDbTransaction = oleDbConnection.BeginTransaction
oleDbCommand.CommandType = CommandType.StoredProcedure
oleDbCommand.CommandText = strOleDbCommandText
oleDbCommand.Transaction = OleDbTransaction
oleDbCommand.Parameters.Clear()
'Creating parameters.
oleDbCommand.Parameters.Add(New OleDbParameter("ConceptName",
OleDbType.VarChar)).Direction = ParameterDirection.Input
oleDbCommand.Parameters.Add(New OleDbParameter("FirstTrans",
OleDbType.Integer)).Direction = ParameterDirection.Input
oleDbCommand.Parameters.Add(New OleDbParameter("LastTrans",
OleDbType.Integer, 15, ParameterDirection.InputOutput, False, CType(15,
Byte), CType(32, Byte), "LastTrans", DataRowVersion.Current, Nothing))
'Assigning value to the parameters.
oleDbCommand.Parameters("ConceptName").Value = "test"
oleDbCommand.Parameters("FirstTrans").Value = 1009209
oleDbCommand.Parameters("LastTrans").Value = 1009578
oleDbCommand.ExecuteNonQuery()
oleDbCommand.Transaction.Rollback()
Thanks,
Shawn
using an OleDbTransaction object so that if anything goes wrong the
transaction is not commited and the new record is not inserted. The problem
is that the transaction is carried out regardless of the commit method is
called or not. This code for instance even has a RollBack, but it still
inserts the new record. Can somebody please tell me what I'm doing wrong?
Dim oleDbConnection As OleDbConnection
Dim strOleDbConnectionString As String = _
"Provider=OraOLEDB.Oracle;" & _
"Data Source=xxx;" & _
"User Id=xxx;" & _
"Password=xxxx"
oleDbConnection = New OleDbConnection(strOleDbConnectionString)
oleDbConnection.Open()
Dim oleDbCommand As OleDbCommand
oleDbCommand = New OleDbCommand()
oleDbCommand.Connection = oleDbConnection
OleDbTransaction = oleDbConnection.BeginTransaction
oleDbCommand.CommandType = CommandType.StoredProcedure
oleDbCommand.CommandText = strOleDbCommandText
oleDbCommand.Transaction = OleDbTransaction
oleDbCommand.Parameters.Clear()
'Creating parameters.
oleDbCommand.Parameters.Add(New OleDbParameter("ConceptName",
OleDbType.VarChar)).Direction = ParameterDirection.Input
oleDbCommand.Parameters.Add(New OleDbParameter("FirstTrans",
OleDbType.Integer)).Direction = ParameterDirection.Input
oleDbCommand.Parameters.Add(New OleDbParameter("LastTrans",
OleDbType.Integer, 15, ParameterDirection.InputOutput, False, CType(15,
Byte), CType(32, Byte), "LastTrans", DataRowVersion.Current, Nothing))
'Assigning value to the parameters.
oleDbCommand.Parameters("ConceptName").Value = "test"
oleDbCommand.Parameters("FirstTrans").Value = 1009209
oleDbCommand.Parameters("LastTrans").Value = 1009578
oleDbCommand.ExecuteNonQuery()
oleDbCommand.Transaction.Rollback()
Thanks,
Shawn