Database Connection

Hello. I am very new to C# and I barely know anything. I was wondering if somebody could show me how to connect and use a SQL database for a login form in a C# .NET WinForm.
10 Replies
Buddy
Buddy8mo ago
Is it for a program you intend to release?
Pobiega
Pobiega8mo ago
You have two choices - "direct" connection via something called ADO, or using a library to help manage the data, called an ORM. There are several ORMs in C#, but the most commonly used one is EntityFramework Core However, the question asked above is important. Is this just for learning, or is it actually for a program you plan to release to the public? Because doing manual SQL queries to a local database is fine for learning, but if you plan to release this, it means the users must have their own SQL databases, or worse, you have to expose a database to the internet with valid credentials "hidden" inside the program. Thats a major security flaw.
EthanTheGreat
EthanTheGreatOP8mo ago
I am looking for the database to work on different computers. But, security is not an issue because this won't be used as a real program or service. I am making this for learning purposes. I want to learn how to connect a database and use it with a login form and then give other people the build and it will still work. Also, thank you so much for both you responding so fast and willing to help. Sorry for the very delayed response.
Pobiega
Pobiega8mo ago
So you want the database to be local to the app, or a shared database for all users? if its local to the app, just use SQLite and you're golden. if you want a shared database, you'll need to set up a webapi that acts as a gateway to the database, and find hosting for it
EthanTheGreat
EthanTheGreatOP8mo ago
I am not sure. But, if I give the program to my friend the login should work as it did on my device.
Pobiega
Pobiega8mo ago
That means a shared database. This is significantly more work and involves hosting, as your program needs a way to "call home" to the database
EthanTheGreat
EthanTheGreatOP8mo ago
what can I use to host my database?
Pobiega
Pobiega8mo ago
A $vps
Pobiega
Pobiega8mo ago
You will also need hosting for the api, which can be done with the same vps
Want results from more Discord servers?
Add your server