conferencedb.vb

来自「visual studio.net 学习资料」· VB 代码 · 共 60 行

VB
60
字号
Imports System
Imports System.Web
Imports System.Collections

Namespace Conference

    '*******************************************************
    '
    ' Conference Class
    '
    ' A helper Class that encapsulates (and then caches) a 
    ' call out to the ASP+ Config System to obtain a database DSN.  
    ' Administrators can change the application's database
    ' location simply by altering the config.web file in the 
    ' root directory of the application.
    '
    '*******************************************************

    Public Class ConferenceDB 
       
        Shared m_ConnectionString As String

        '*******************************************************
        '
        ' ConferenceDB.ConnectionString Property
        '
        ' The ConferenceDB.ConnectionString property encapsulates
        ' a callout to the ASP+ Config System to obtain the
        ' database connection string for the application.
        '
        '*******************************************************

        Shared ReadOnly Property ConnectionString As String   
        
            Get  

                ' Pull the ConnectionString from the ASP+ AppSettings section.
                ' Cache in static field for faster repeat access.

                If m_ConnectionString = "" Then

                    Dim appsetting As Hashtable = CType(HttpContext.Current.GetConfig("appsettings"), Hashtable)         
                    m_ConnectionString = CStr(appsetting("DSN"))

                    If m_ConnectionString = "" Then
                        throw new Exception("Conference DSN Value not set in Config.web")
                    End if

                End If

                ' Return the Connection String
                return m_connectionString

            End Get
            
        End Property
        
    End Class
    
End Namespace

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?