StrataFrame Forum

Testing flag routing to Testing Database

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

By Charles Thomas Blankenship - 4/22/2014

Where is the best place to put a flag that switches the DataSourceKey from the actual database ("Crucible" in this case) to a testing database ("CrucibleTesting").

I tried placing it in the Constructor of the Base Business Object like so ... but it is still routing to the production database:




public BaseBusinessLayer():base()
{
   InitializeComponent();
   if (CommonCalls.AppConfig.IsTesting)
   {
      DataSourceKey = "CrucibleTesting";
   }
} 
By Charles Thomas Blankenship - 4/22/2014

I know there is an example application that shows how to use the connection manager (launches a dialog) to change the DataSource but I can't find it anymore.
By Edhy Rijo - 4/22/2014

Hi Charles,

I handle that via the Connection Manager in which I create connections for different databases and servers to test live data from my customer's database directly.

I have a menu item in my DevExpress Ribbon menu to do this, here is the vb code:

    ''' <summary>
    ''' Sets the database connection
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub SetDatabaseConnection()
        '-- Check security for this module
        If Not Basics.HasPermission("Database Connection") Then
            Exit Sub
        End If

        '-- Show the connection dialog and allow a connection to be selected
        If MicroFour.StrataFrame.Data.ConnectionManager.ShowAvailableConnectionStrings() Then
            '-- Since a connection was selected, then all of the existing dialogs need to be closed
            '   since their connection is established to the original source.
            For Each loForm As Form In Me.MdiChildren
                loForm.Close()
                loForm.Dispose()
            Next

            '-- Force the connections to be reset
            MicroFour.StrataFrame.Data.ConnectionManager.SetConnections()

            '-- Set the Connection label on the status bar
            Me.RibbonControl_MainForm.Items("sbConnectedToItem").Caption = "Connected to: " & GetApplicationActiveConnectionStringTitle(ConnectionManager.ApplicationKey, "")
        End If
    End Sub


The code does not handle all possible validations to test if a form could not be closed because I normally don't allow access to the end users to choose the connection, this is done by me or somebody else I assign to handle this.

Enjoy!!!
By Charles Thomas Blankenship - 4/23/2014

Thanks ... I knew it had something to do with the ConnectionManager ... just couldn't remember ...