5

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?

1

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Regardless of how you build the connection string, it needs to get into your config file which is supported by ConfigurationManager as long as the user has rights to save the config file in the location where it's being installed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.