Imports DigitalData.Modules.Database

Public Class ProfileUtils
    Public Shared Function GetConnectionString(Database As MSSQLServer, ConnectionId As Integer) As String
        Dim oDatatable As DataTable = Database.GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {ConnectionId}")

        If oDatatable.Rows.Count > 0 Then
            Dim oRow As DataRow = oDatatable.Rows.Item(0)

            Select Case oRow.Item("SQL_PROVIDER")
                Case "MS-SQL"

                    Dim oConnectionString = Database.GetConnectionString(oRow.Item("SERVER"), oRow.Item("DATENBANK"), oRow.Item("USERNAME"), oRow.Item("PASSWORD"))
                    oConnectionString = MSSQLServer.DecryptConnectionString(oConnectionString)
                    Return oConnectionString

                Case Else
                    Return Nothing

            End Select
        Else
            Return Nothing
        End If
    End Function
End Class
