ODP.NET Code Example Critque or best practices
Posted
by andrewWinn
on Stack Overflow
See other posts from Stack Overflow
or by andrewWinn
Published on 2009-08-13T12:06:17Z
Indexed on
2010/03/28
4:03 UTC
Read the original article
Hit count: 405
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
© Stack Overflow or respective owner