VisualBasic.net Database Boiler Plate
- by Shiftbit
Is there any built in .net Classes to assist in the reduction of boiler plate code? I have numerous database operations going on and I find that I am reproducing the connection, command, transaction and occassianlly data set.
I am aware of the Java Related Question, however, the solutions pertain to Java. I was wondering if anyone was aware of a .net solution? http://stackoverflow.com/questions/1072925/remove-boilerplate-from-db-code
Public Sub ReadData(ByVal connectionString As String)
Dim queryString As String = "SELECT EmpNo, EName FROM Emp"
Using connection As New OracleConnection(connectionString)
Dim command As New OracleCommand(queryString, connection)
connection.Open()
Using reader As OracleDataReader = command.ExecuteReader()
' Always call Read before accessing data.
While reader.Read()
Console.WriteLine(reader.GetInt32(0).ToString() + ", " _
+ reader.GetString(1))
End While
End Using
End Using
End Sub
MSDN