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?
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.
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?
Do you have any comment on this one?
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.
Thanks a lot!