Programmically Connecting to Multiple Databases using Same BOs


Author
Message
Jeff Pagley
Jeff Pagley
StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
Thanks for the help!

Jeff
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Jeff Pagley (6/16/2011)
Thanks Edhy for the reply.  I use the Connection Manager now. But I need to clarify what I want to do.  I need to have 4 connectionsopen at the same time to 4 different databases within the same application andthen have the BOs use those 4 connections for CRUD operations.  Is this possible?

Yes, you can have as many connections open as you want.  In the AppMain.vb or Program.cs add a data source item in the SetDataSources method for each database.  Make sure you fill the DataSourceKey parameter for each one, then you can set the BO.DataSourceKey to use the connection you want to get the data from.

Edhy Rijo

Jeff Pagley
Jeff Pagley
StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
Thanks Edhy for the reply.  I use the Connection Manager now. But I need to clarify what I want to do.  I need to have 4 connectionsopen at the same time to 4 different databases within the same application andthen have the BOs use those 4 connections for CRUD operations.  Is this possible?

Jeff


Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Jeff,

If you need to connect to this different database one at a time, you can create as many connections as you want with the SF Connection Manager and simply change the connection to the one you want to work with.  I do this all the time to remotely connect to my customers data to generate reports or test some new functionality with current data.

To go this route, simply call the connection manager from a menu item or somewhere else you want to be able to select from your connections, here is the vb code I use just for that, feel free to adjust it to suit your needs.


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.Items("sbConnectedToItem").Caption = "Connected to: " & GetApplicationActiveConnectionStringTitle(ConnectionManager.ApplicationKey, "")
         End If
 End Sub



Edhy Rijo

Jeff Pagley
Jeff Pagley
StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)StrataFrame User (469 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893

Hi SF Team,

I have an unusual challenge I need some help on.  I will be creating new databases with thesame schema on a regular basis on the same server.  Therefore, I will not only have existingdatabases, but I will constantly have new ones. Within one single application I need to be able to randomly select  any four of these databases and in some wayuse the same BO classes to connect and CRUD to each database.  Any suggestions on how I might be able to dothis? 

Thanks,

Jeff 


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