Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a connection string from a user's input in a WPF application

If we want in our WPF application to let a user make a SQL Server db connection settings through dialog window, what approach we should use in implementing this.

Should we programmatically make changes to the app.config file? Or, some another approach exists? Or, maybe, in WPF there is some prebuilt tools for doing this?

like image 945
rem Avatar asked Feb 26 '10 20:02

rem


1 Answers

You could always use one of the built-in dialogs. There is an ADODB connection dialog that requires COM interop. There's also one that has a dependency on a Visual Studio DLL.

But Microsoft has also released the source code to the standard connection dialog available on Code Gallery.

As far as storing the connection string, I would avoid assuming you can write to the App.config unless your application is being installed on a per-user basis. Instead I would store it as a user-scoped setting. If you will allow the user to store the password in the connection string, you should first encrypt the string using the ProtectedData class. Note that you should probably use the per-user scope when encrypting.

like image 94
Josh Avatar answered Sep 30 '22 00:09

Josh