VisualBasic.net Database Boiler Plate

Posted by Shiftbit on Stack Overflow See other posts from Stack Overflow or by Shiftbit
Published on 2010-05-19T15:49:28Z Indexed on 2010/05/19 16:10 UTC
Read the original article Hit count: 342

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about database-connection