Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Class clsSQLDataConnection
#Region " My Constants "
Private Const sDefaultServer As String = "SQLSERVER"
Private Const sDefaultDatabase As String = "Master"
Private Const sDefaultUser As String = "sa"
Private Const sDefaultPassword As String = ""
Private Const iDefaultTimeOut As Integer = 10
Private Const sDefaultPooling As String = "false"
#End Region
#Region " My Properties "
Public Property oConnection() As SqlConnection
Get
Return varConnection
End Get
Set(ByVal Value As SqlConnection)
varConnection = Value
End Set
End Property : Private varConnection As SqlConnection
Private Property sConnectionString() As String
Get
Return varConnectionString
End Get
Set(ByVal Value As String)
varConnectionString = Value
Me.oConnection = New SqlConnection(Value)
End Set
End Property : Private varConnectionString As String
Public ReadOnly Property oConnectionState() As System.Data.ConnectionState
Get
Return Me.oConnection.State
End Get
End Property
Public ReadOnly Property oError() As Exception
Get
Return varError
End Get
End Property : Private varError As Exception
#End Region
#Region " My New "
Public Sub New()
Dim sb As New Text.StringBuilder
sb.Append("Server=" & Me.sDefaultServer & ";")
sb.Append("DataBase=" & Me.sDefaultDatabase & ";")
sb.Append("User ID=" & Me.sDefaultUser & ";")
sb.Append("Password=" & Me.sDefaultPassword & ";")
sb.Append("Connect Timeout=" & Me.iDefaultTimeOut & ";")
sb.Append("Pooling=" & Me.sDefaultPooling & ";")
Me.sConnectionString = sb.ToString
End Sub
Public Sub New(ByVal sConnectionString As String)
Me.sConnectionString = sConnectionString
End Sub
Public Sub New(ByVal sServer As String, ByVal sDatabase As String, ByVal sUser As String, ByVal sPassword As String, Optional ByVal iTimeout As Integer = iDefaultTimeOut)
Dim sb As New Text.StringBuilder
sb.Append("Server=" & sServer & ";")
sb.Append("DataBase=" & sDatabase & ";")
sb.Append("User ID=" & sUser & ";")
sb.Append("Password=" & sPassword & ";")
sb.Append("Connect Timeout=" & iTimeout & ";")
sb.Append("Pooling=" & Me.sDefaultPooling & ";")
Me.sConnectionString = sb.ToString
End Sub
#End Region
#Region " My Methods "
Public Function bConnect() As Boolean
If Me.oConnectionState = ConnectionState.Open Then Return True
Try
Me.oConnection.Open()
Return True
Catch ex As Exception
Me.varError = ex
Return False
End Try
End Function
Public Function bDisconnect() As Boolean
If Me.oConnectionState = ConnectionState.Closed Then Return True
Try
Me.oConnection.Close()
Return True
Catch ex As Exception
Me.varError = ex
Return False
End Try
End Function
Public Sub zDispose()
Me.oConnection.Dispose()
End Sub
#End Region
End Class