Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Imports System.Text

Public Class Connection

#Region "Properties"

    Dim _server As String
    Dim _database As String
    Dim _dbserver As String
    Dim _username As String
    Dim _password As String
    Dim _isActive As Boolean
    Dim _trusted As Boolean

    Public Property server() As String
        Get
            Return _server
        End Get
        Set(ByVal value As String)
            _server = value
        End Set
    End Property

    Public Property database() As String
        Get
            Return _database
        End Get
        Set(ByVal value As String)
            _database = value
        End Set
    End Property

    Public Property dbserver() As String
        Get
            Return _dbserver
        End Get
        Set(ByVal value As String)
            _dbserver = value
        End Set
    End Property

    Public Property username() As String
        Get
            Return _username
        End Get
        Set(ByVal value As String)
            _username = value
        End Set
    End Property

    Public Property password() As String
        Get
            Return _password
        End Get
        Set(ByVal value As String)
            _password = value
        End Set
    End Property

    Public Property isTrusted() As Boolean
        Get
            Return _trusted
        End Get
        Set(ByVal value As Boolean)
            _trusted = value
        End Set
    End Property

    Public ReadOnly Property cnStr() As String
        Get
            Dim conn As String = String.Empty

            Select Case Me.dbserver
                Case "DBF"
                    conn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                           "Data Source=" & Me.server & "\" & Me.database & ";" & _
                           "Extended Properties=dBASE IV;text;HDR=Yes;FMT=Delimited(,);CharacterSet=65001" & _
                           "User ID=" & Me.username & ";" & _
                           "Password=" & Me.password & ";"
                Case "SQL Server"

                    If Me.isTrusted = True Then
                        conn = "Data Source=" & Me.server & ";" & _
                           "Initial Catalog=" & Me.database & ";" & _
                           "Trusted_Connection=False"                   
                    Else

                        conn = "Data Source=" & Me.server & ";" & _
                           "Initial Catalog=" & Me.database & ";" & _
                           "User ID=" & Me.username & ";" & _
                           "Password=" & Me.password & ";"
                    End If
            End Select

            Return conn

        End Get
    End Property

#End Region

End Class
