I am writing an application (VB 2005.net) that will be installed on different sites; hence the Connection string needs to change depending on the location. How can get the application to change the connection string that have been setup in the Project /settings when developing the application, to a different connection depending on the < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Location i.e. different SQL server
EG developed on Myserver\dev need to be run on newsever\prod or oldserver\UAT

Connecting to Different servers
Surreal
You could save an encrypted string in the registry.
tigger30
<ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vssoln/html/35254321-ad14-47d9-b8c6-39ab3203c5d9.htm>
Application Settings
Application settings allow you to store and retrieve property settings and other information for your application dynamically, and they allow you to maintain custom application and user preferences on the client computer. Often this is data (such as a connection string) critical to running the application that you do not want to include directly in the application's code. You might want to store two different database connection strings and retrieve one of them at run time based on the computer's location. Or, you might want to store a user's color preferences, then retrieve them the next time the application runs.
Notice that application settings are a Microsoft Visual Studio 2005 feature that replaces the dynamic properties feature in the previous version (for information on dynamic properties, see Configuring Applications Using Dynamic Properties).
Each application setting must have a unique name; the name can be any combination of letters, numbers, or an underscore that does not start with a number, and cannot contain spaces. The name can be changed through the Name property.
Application settings can be stored as any data type that is XML serializable or has a TypeConverter that implements ToString/FromString. The most common types are String, Integer, and Boolean, but you can also store values as < XML:NAMESPACE PREFIX = MSHelp NS = "http://msdn.microsoft.com/mshelp" />Color , Object , or as a connection string.
Application settings also contain a value. The value is set with the Value property and must match the data type of the setting.
In addition, application settings can be bound directly to a property of a form or control at design time. For more information, see How to: Add or Remove Application Settings.
There are two types of application settings, based on scope:
Application-scoped settings can be used for information such as a URL for a Web service or a database connection string. These values are associated with the application, so users cannot change them at run time.
User-scoped settings can be used for information such as remembering the last position of a form or a font preference. Users can change these values at run time.
You can change the type of a setting using the Scope property.
The project system stores application settings in two XML files: an app.config file, which is created at design time when you create the first application setting; and a user.config file, which is created at run time when the user running the application changes the value of any user setting. Notice that changes in user settings are not written to disk unless the application specifically calls a method to do so.
Creating Application Settings at Design Time
At design time, you can create application settings in two ways: with the Settings page of the Project Designer, or with the Properties window for a form or control, allowing you to bind a setting directly to a property. For more information, see How to: Add or Remove Application Settings.
When you create an application-scoped setting (for example, a database connection string, or a reference to server resources), Visual Studio saves it in app.config with the
<applicationSettings>tag (connection strings are saved under the<connectionStrings>tag.)When you create a user-scoped setting (for example, default font, home page, or window size), Visual Studio saves it in app.config with the
<userSettings>tag.When you store connection strings in app.config, you should take precautions to avoid revealing sensitive information, such as passwords or server paths, in the connection string,.
If you take a connection string information from an external source, such as a user supplying a user ID and password, you must take care to ensure that the values you use to construct your connection string do not contain additional connection string parameters that change the behavior of your connection.
Consider using the Protected Configuration feature to encrypt sensitive information in the configuration file. SeeSecuring Connection Strings for more information.
Because there is no configuration file model for class libraries, application settings do not apply for Class Library projects. The exception is a Visual Studio Tools for Office DLL project, which can have a configuration file.
Accessing or Changing Application Settings at Run Time in Visual Basic
This section applies only to Visual Basic projects.
At run time, you can access application settings using the My.Settings object. On the Settings page, click the View code button to view the Settings.vb file (for more information, see How to: Access Settings Events). Settings.vb defines the Settings class, which allows you to handle these events on the settings class:SettingChanging , PropertyChanged , SettingsLoaded , and SettingsSaving . Notice that the Settings class in Settings.vb is a partial class, showing only the user-owned code, not the whole generated class. For more information on accessing application settings using the My.Settings object, see Accessing Application Settings .
The values of any user-scoped settings that the user changes at run time (for example, the position of a form) are stored in a user.config file. Notice that the default values are still saved in app.config.
If you have changed any user-scoped settings during run time, for example in testing the application, and want to reset these settings to their default values, click the Synchronize button. For information on this control, seeSettings Page, Project Designer .</>
JHPE
Initialize the connection string during setup and store the string (ie in the Registry)...
Initializing the string can be done progmatically or by prompting the user ..its up to you and your senerio...Just an Idea...
kwarnke
You could use the technique described in:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=84782&SiteID=1
to morph your connection string into a user scoped setting...
Best regards,
Johan Stenberg
MayaMan