Ability to programatically set the Application Active Connection String


Author
Message
Peter Denton
Peter Denton
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: Forum Members
Posts: 77, Visits: 787
G'day

We have a suite of programs that will run on a single dedicated server via numerous terminal server sessions, with every program in every session for every user accessing the same database which is usually on a second dedicated server. When the second server fails (which it will), we need to be able to be able to have the user quickly swap the connection to the database on the Application server (which is transactionally replicated from the database server). The users we deal with are shop floor supervisors in a very low tech industry (Leather Tanning), and this is a task that we may have to direct them to do after having been woken up at 4am in the morning by a phone call from the other side of the country, and that has to be done quickly because production will have stopped with potentially 50 workers standing around waiting, so simplicity is essential. I want to provide a form with a single button, that upon pressing the button will swap the connection for them and confirm that it has been done (with appropriate safeguards to ensure it isn't done accidently, i.e. limit the access to a single user specific to the task e.g. user id "Swap").

ConnectionManager.ShowAvailableConnectionStrings() is a convenient way of maintaining the connection strings, and the "Select" capability does what we want, except for the fact that the user performing the task could have the wrong connection selected at the time (our users are not renowned for their clarity at describing what is on the screen in front of them at such times, or any other times for that matter). We would use it for configuring the system while on-site installing. And switching servers is an installation test we always perform, to ensure that we have the settings right.

What I would find useful would be

public function SetApplicationActiveConnectionString(ByVal ApplicationKey as String, _
                                                                        ByVal DataSourceKey As String, _
                                                                        ByVal ApplicationDefaultTitle As String) _
                                                                        As Boolean

which would do just as pressing the "Select"  in ShowAvailableConnectionStrings does returning true if sucessful false otherwise (i.e. there is no connection string for the given combination).

Any chance of something like this?

I have investigated storing Connection Strings in each App's .config, but then I have a problem with ensuring that they are all kept in sync, and I don't really want to reinvent the wheel.

Peter


Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Really Peter, you will probably not want to use the connection manager at all in this case but rather create a solution on your side to just manually add the data sources.  This is actually what we do within our medical software (along with a number of other things).  We actually prevent our end-users from ever entering a connection string on the client side altogether as we have a server service that we distribute with our medical software which "tells" all of the clients what their connection string will be.  Now you don't have to take this approach, but you will still want to manually create your data source connections (which ultimately may save some installation steps anyway for your end-user).

To manually setup a connection string within the AppMain.vb, just comment out the SetConnections line...this is what forces the Connection Manager to do its thing.

Instead, manually add a connection like this:

MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(New SqlDataSourceItem("","MyConnectionSTring"))

That is how you manually provide a connection string.  Now you can get more sophisticated as to how the end-user to obtain this connection.  As previously mentioned, we have a server service that all of the clients connection to first via an http request (you can also use a TCP socket).  If the server cannot be found, a UDP broadcast is sent out to which the server will listen and then respond with it's own IP so the client knows how to connection to it...once the client knows the IP of the server, it connects on a particular port, and then the server gives it the connection string that needs to be used.

This is probably not the approach that you need, but it might get some wheels turing as to how you may need to connect.  One other thought is that you can have a dialog that pops up with a combo asking which location a user is at or which database to which they want to connection which is populated froma network shared file.  Once selected then you would know how to connect...this is just another approach and idea.

Hope this helps Smile

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