Connection strings in WinForms?
How can I use the Connectionstring more effectively and securely in basic Winform C#?
6 Replies
Elaborate
writing a simple Winform with a SQL connection. I'm not sure where to declare the connection—in the main class or somewhere else—and I need to encrypt my connection string in order to connect to SQL if possible.
You'd probably use some config file — resource, JSON file, something like that — to store connection details
Encrypting the connection string won't work, since you will need the encryption key on the client side as well
If you want to protect access to the database, hide it behing an API and call that API from your Winforms app, instead of connecting to the database directly
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
But then anyone else can consume that api and get the connection string or access to the DB?😭
Can consume the API, yes
But you can require authorization
Like, say, logging in
Or a license key
Or something of the sort