ODP.NET Code Example Critque or best practices
- by andrewWinn
I currently have a DataAccess Layer in Vb.Net. I am not too happy with my implementation of both my ExecuteQuery (as DataSet) and ExecuteNonQuery functions. Does anyone have any code that I could see? My code just doesn't look clean. Any thoughts or critiques on it would be appreciated also.
Using odpConn As OracleConnection = New OracleConnection(_myConnString)
odpConn.Open()
If _beginTransaction Then
txn = odpConn.BeginTransaction(IsolationLevel.Serializable)
End If
Try
Using odpCmd As OracleCommand = odpConn.CreateCommand()
odpCmd.CommandType = CommandType.Text
odpCmd.CommandText = sSql
For i = 0 To parameters.Parameters.Count - 1
Dim prm As New OracleParameter
prm = DirectCast(parameters.Parameters(i), ICloneable).Clone
odpCmd.Parameters.Add(prm)
Next
If (odpConn.State = ConnectionState.Closed) Then
odpConn.Open()
End If
iToReturn = odpCmd.ExecuteNonQuery()
If _beginTransaction Then
txn.Commit()
End If
End Using
Catch
txn.Rollback()
End Try
End Using