I created an application in C# + WPF + MySQL. What is the best (safest) way to store database connection strings?
Connection strings in configuration files are typically stored inside the <connectionStrings> element in the app. config for a Windows application, or the web. config file for an ASP.NET application.
If you have a valid reason to keep it open, then do so. If not, close it as soon as you're done with it. But it's better to be in the good habit of closing the connections so that you don't just leave them open when you don't intend to.
config file, instead of hard coding it. But I find it very dangerous, especially in cases where the same connection string is used for all users. This means anyone who's got access to the web config file can easily get the username and password to the database and do all kinds of serious things.
ANSWER: In Web. config file.
Store it on your App.config file and always encrypt it. This link will show you how to encrypt parts of your configuration file.
You could store connections strings in the configuration file. You may secure them if necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With