Navigation

Search

Categories

On this page

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 125
This Year: 63
This Month: 4
This Week: 1
Comments: 0

Sign In

 Wednesday, July 16, 2008
Wednesday, July 16, 2008 12:35:23 PM (Eastern Standard Time, UTC-05:00) ( )
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Collections.Generic

Public Class AwesomeDataLayer
    Private Shared ReadOnly _connectionString As String
Private Sub Page_Load()
        lblMovieTitle.Text = GetMovieTitle().ToString()
End Sub
       Public Shared Function GetMovieTitle() As String
        Dim result As String = String.Empty
        Dim con As New SqlConnection(_connectionString)
        Dim cmd As New SqlCommand("GetMovieTitle", con)
        cmd.CommandType = CommandType.StoredProcedure
        Using con
            con.Open()
            Dim reader As SqlDataReader = cmd.ExecuteReader()
            If reader.Read() Then
                result = CType(reader("Title"), String)
            End If
        End Using
        Return result
    End Function

    Shared Sub New()
        _connectionString = WebConfigurationManager.ConnectionStrings("MyDatabase").ConnectionString
    End Sub

End Class
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):