Testing flag routing to Testing Database


Author
Message
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
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";
   }
} 


Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
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.

Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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!!!

Edhy Rijo

Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
Thanks ... I knew it had something to do with the ConnectionManager ... just couldn't remember ...

Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search