Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection String management for a desktop application

I created a desktop application in C#/WPF which connects to a SQL Server 2008 instance through a constant connection string specified in code as follows (for testing purposes):

private string GetConnectionString()
{
    //test
    return "Data Source=[server IP]; Initial Catalog=[database name]; User ID=[user ID]; Password=[smart password];";
}

The application will be used by various users and will be deployed via ClickOnce, a .zip archive or a custom installer. It also has a separated custom login functionality by requesting an application-access username and password.

Which is the best practice to store the connection string details for my desktop application (IP, database, SQL Server user, password)? If the connection string changes over night, which is the best method to update it without forcing users to update to the latest version of my application? Users should not be able to see/intercept/decompile the connection string, so I guess I must use some sort of encryption. Do you have any kind of suggestion for my inquiry?

like image 405
Claudiu Constantin Avatar asked Jul 05 '26 22:07

Claudiu Constantin


1 Answers

Even if you compile your connection strings into the application, they still can be viewed using the Ildasm.exe (MSIL Disassembler) tool because strings are a part of assembly's metadata.

Maybe this question can help you.

like image 68
Yuriy Guts Avatar answered Jul 08 '26 14:07

Yuriy Guts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!