StrataFrame Forum

How to read the current DB connection Title?

http://forum.strataframe.net/Topic20823.aspx

By Edhy Rijo - 11/21/2008

Hi,

I have several database connections (Local, Remote, etc), so I can do my test, I want to show in the main form the "Title" of the currently selected database connection, so I know which server I am connecting to without having to call the Database Connection Wizard to see this info.

How can I programmatically get the "Title" info of the current connection?

By Ivan George Borges - 11/21/2008

Hi Edhy.

I think you would have to fill a load a dataset with the "AppKeys.dat" (OpenXmlFile), CopyDataFrom this dataset table into a BO and then work with it, as it would be filled with your connections' data.

By Edhy Rijo - 11/21/2008

Hi Ivan,

Sounds like a bit complicate, is not a property in the connection manager class that will have this info? or a method in there somewhere to get this info?

By Ivan George Borges - 11/21/2008

It might be, but I don't know of any... which doesn't mean much! BigGrin
By Edhy Rijo - 11/21/2008

Hi Trent,

Do you have any comment on this one?

By Trent L. Taylor - 11/21/2008

Here you go Smile

Imports MicroFour.StrataFrame.Data
Imports MicroFour.StrataFrame.Data.BusinessObjects

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox(GetApplicationActiveConnectionStringTitle(ConnectionManager.ApplicationKey, ""))
    End Sub

    ''' <summary>
    ''' Returns the active connection string for an application and a specified data source key.
    ''' </summary>
    ''' <param name="ApplicationKey"></param>
    ''' <param name="DataSourceKey"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetApplicationActiveConnectionStringTitle(ByVal ApplicationKey As String, ByVal DataSourceKey As String) As String
        '-- Establish Locals
        Dim loAppData As New DbeApplicationData()
        Dim r As String = ""

        '-- Load the application data
        loAppData.FillWithActiveKey(ApplicationKey)

        '-- See if the application key was found
        If loAppData.Count > 0 Then
            r = loAppData.app_title
        End If

        '-- Clean Up
        loAppData.Dispose()

        '-- Return Results
        Return r
    End Function

End Class

Just FYI, the GetApplicationActiveConnectionStringTitle method is all you need....I just created a test for and threw all of the code in there.

By Edhy Rijo - 11/21/2008

Thanks Trent, I will test it.
By Edhy Rijo - 11/21/2008

Yeap, just what I need, I will add this to my main form base class.

Thanks a lot!

By Dustin Taylor - 11/24/2008

On behalf of Trent: "No problem, glad you got it working!.... Go Cowboys."

BigGrin