Where should I store the database connection string?

I created an application in C # + WPF + MySQL. What is the best (secure) way to store database connection strings?

+7
c # mysql wpf
source share
6 answers

You can store connection strings in a configuration file . You can provide them if necessary.

+5
source share

Save it in the App.config file and always encrypt it. This link will show you how to encrypt parts of your configuration file.

+5
source share

Alternatively, a registry. The only place you don’t store them is the app.config file (whatever.exe.config), because it exists only once, and the program folder is not something that users can change. There should never be any custom settings.

+2
source share

If the application is running on a server, I would recommend the machine.config file and encrypt it in the same estate that Fernando recommended. If the application is distributed, then app.config will store it.

+1
source share

You can use the visual studio settings / properties available when using visual studio. They are quite easy to use, and if you use user preference, it is stored in the application data directory for the user, therefore it is hidden from interference. Then all you have to do is some form of encryption to completely block it if you want to.

I think the best thing about visual studio settings is ease of use.

0
source share

Well, I always follow one practice. When I ever do something in SL or WPF, I always add a Service layer between SL / WPF and the database.

0
source share

All Articles