I am using an Oracle 11g client with ODP.NET. I am trying to add conditional transaction processing.
Dim ds As New DataSet()
Dim txn As OracleTransaction
Dim _beginTransaction as Bolean = true
Using conn As New OracleConnection(ConnString)
Try
conn.Open()
If _beginTransaction Then
txn = conn.BeginTransaction(IsolationLevel.Serializable)
End If
Dim adapter As OracleDataAdapter = New OracleDataAdapter()
adapter.SelectCommand = New OracleCommand(sSQL, conn)
For i As Integer = 0 To UBound(parameters, 1)
adapter.SelectCommand.Parameters.Add(parameters(i))
Next
adapter.Fill(ds)
If _beginTransaction Then
txn.Commit() //txn is undefined here? why?
End If
Catch e As Exception
txn.Rollback()
End Try
End Using
How to set txn as nothing / null? Error: The variable "txn" is used before it is assigned a value. An exceptional link exception may occur at runtime. Links or pointers to solutions will also be appreciated.
:. RichardOD , , ODP.NET. , . , . , txn w/ if, try/catch .... ? ?