I have a VB.NET application with a connection to an SQL Server 2003. On the server there are two databases, MyDatabase and MyDatabase_Test. What I would like to do is to show a dialog when the program starts that let's the user choose which database to use. My idea is to create a new form as the starup form that sets this property and then launches the main form.
Currently the connectionstring is specified in the application config file. Best would be if I can specify two different connection strings in that file to choose from, but for now it is also acceptable with other solutions like hardcoding the two connectionstrings into the startup form.
EDIT: In the dataset.xsd file there seems to be the relevant part
<Connections>
<Connection AppSettingsObjectName="MySettings" AppSettingsPropertyName="MyDatabase_ConnectionString" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="MyDatabase_ConnectionString(MySettings)" ParameterPrefix="@" PropertyReference="ApplicationSettings.MyProgram.My.MySettings.GlobalReference.Default.MyDatabase_ConnectionString" Provider="System.Data.SqlClient" />
</Connections>
But how do I change it at runtime? The closest i could find is changing which connection is used for every single TableAdapter but that doesn't seem very optimal.
EDIT2: I agree that a modal dialog at startup would be better, but where would i launch it so that it is done before the database connection is initiated?
EDIT3: Eventually I "solved" it by removing the ReadOnly from the settings file. This will be removed each time the file is auto-generated though, so it's not optimal.
EDIT4: A better solution seemed to be using a user scoped string instead of a connection string to link the dataset and fetched the value for that string from the two application scoped ConnectionStrings.