Connection strings in WinForms?

How can I use the Connectionstring more effectively and securely in basic Winform C#?
6 Replies
Angius
Angius3mo ago
Elaborate
Anburaj Marikkani
Anburaj MarikkaniOP3mo ago
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.
Angius
Angius3mo ago
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
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
VRose
VRose3mo ago
But then anyone else can consume that api and get the connection string or access to the DB?😭
Angius
Angius3mo ago
Can consume the API, yes But you can require authorization Like, say, logging in Or a license key Or something of the sort
Want results from more Discord servers?
Add your server