views:

472

answers:

3

Hi,

I created the setup project for the application and I can see that the later modifications of the configuration file (Application.exe.config) don't affect the application execution.

I am developing an application with the database file included and I want to enable users to move the database file and modify connection strings.

Does anyone know what's the best practice for the deployment of the application with the database file?

A: 

did you make sure to remove the settings default values? These are compiled and fetched from the dll and not from the config file.

Alexandre Brisebois
+1  A: 

It should work, provided that you use the exact same connection string setting in your DB access DLL's Settings.settings file and in your application's config file.

An example that works well for me:

 <connectionStrings>
  <add name="YourApp.Properties.Settings.DatabaseConnectionString"
  connectionString="Data Source=localhost;Initial Catalog=xxx;Integrated Security=True;"
  providerName="System.Data.SqlClient" />
 </connectionStrings>

When entered appropriately in both locations (ie. the dll's Settings.settings and the exe's App.config files), this does allow me to change the database connection in YourApp.exe.config before the app runs.

(I assume you already know that you need to change the application's config file, as DLL's do not support the app.config mechanism directly.)

Alan
A: 

Have you checked out using a UDL file? If you save your connection string in the udl file, the user can change the connection via an interface by simply double clicking that file. You can set your connection string in the app to point to the udl file. You can also launch the udl interface programmatically if you want. The only downside to these is if the user saves their password to the file, it is saved as plain text. But this isn't an issue if you are using windows authentication.

Will Rickards