The database I will use is MySQL. I will tell you how to connect a database and how to make a simple login form. To do this, just use the following simple procedure.
Step 1
Open Visual Studio and create a new Windows Forms project.
Step 2
Make a simple form having the 2 text fields username and password and a login button.
Step 3
Now go to the menu bar, select the view option and there you can see “Server Explorer”. Just click on that and the Server Explorer will be opened.
Step 4
Now add your connection. There you can see an option of server name. Here you need to write the name of your server, the same as in your SQL. When you provide the server name, just go to the select option, there you'll see the entire database name that you have made. You can create your new database too.
Step 5
It'll ask for permission and click Yes.
Step 6
Now you'll be able to see your DB in your Server Explorer tab.
Step 7
Click on it. There you'll see tables. To create a new one, right-click on that and add a new table.
Step 8
Now you need to add some data in it. To do so just follow the figure:
Step 9
Now your database is created, we only need to connect it with our form. To do this open your form and double-click on the button you have made. It"ll take you to the code of that button. Here write the following code:
Don't forget to import it's library file.
After this just debug your code.
I hope you have gotten all this. Thank you.