All pastes #413191 Raw Edit

reznor

public text v1 · immutable
#413191 ·published 2007-03-28 05:39 UTC
rendered paste body
    Public Shared ReadOnly Property EmployeeId() As Integer

        Get
            Dim eVideo As SqlConnection = New SqlConnection(DbConnectionString)
            Dim Id As Integer = 0

            'Try
            Dim LookupAccountNumber As SqlCommand = New SqlCommand("exec LookupEmployeeId @LoginId", eVideo)
            LookupAccountNumber.Parameters.Add("@LoginId", SqlDbType.VarChar).Value = System.Threading.Thread.CurrentPrincipal.Identity.Name

            'eVideo.Open()
            Id = CInt(LookupAccountNumber.ExecuteScalar())
            'Finally
            'eVideo.Close()
            'End Try

            If Id <= 0 Then
                Throw New Exception("Caller has no corresponding EmployeeId.")
            End If

            Return Id
        End Get

    End Property