Login Form in Visual Studio 2019 using CSharp / C# - Windows Forms App (.NET Application)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this is the final solution that you can see on the screen we will be developing today in Visual Studio 2019 you can see that once we login we can access our dashboard or our main form so let's start by first creating a new dotnet forms application you can name the solution as login form first you can name the dashboard form as main form then let's add a new component which is a windows form and name it as login form [Music] [Music] I already have some icons so I will assign an icon to this form this will make it more visually appealing [Music] [Music] you now let's add the labels from the tool box and you can aptly-named the labels as username and password labels next we will add two text boxes to accept the user input [Music] [Music] [Music] add the two buttons from the tool box and name them accordingly as logon and exit buttons you can name them from the properties window and also change their text from the same window [Music] [Music] I will now also add a picture box to show a picture of Locke you can refer to the resource folder and then upload images from any folder which will appear on your login form you can choose to stretch the image as per dimensions of picture box let's run the application and you will notice that when we run it we see the dashboard instead of our login form this is because in our main program dot CS file the entry point for our application is dashboard phone we have to change it to refer to our login form when you again run the application now you see it will show our login form [Music] you can add the code under the exit button which is simply application dot exit next we have to add a database file to our project which will host the table for our login information [Music] [Music] now we will add the table to our database file and name it as login table this can be done in the command window as you can see here the two items in our table will be login name or username and password and we declare both as varchar' 15 [Music] once you are done with the variables you can update the database so that it has updated login table [Music] [Music] we can then edit the values in the table and add username as admin and password as admin as an example now we will define the function to make connection with our database and give us the final login functionality but before we do do that let's add some basic validation to check whether our import boxes are empty or populated this will help us avoid empty data to be entered into text boxes which doesn't make any sense you can extend validation to advanced levels by tweaking the same validation function I will keep it simple at the moment [Music] basically you are checking for both username and password fields that they are not empty and if they are then the user is alerted with error message now we can proceed to code for our login button let's first check the validation and then proceed to make connection with our database for this you can use sequel connection function and pass on details on location for your database [Music] [Music] once that is done you have to declare sequel query which will finally check our database for presence of username and password values in relevant fields in relevant table our query will be a simple select query checking for presence of username and password in the login table [Music] [Music] once you write the full query then you have to use sequel adapter function which will take the query as one argument in our connection variable as the second argument [Music] then define a simple data table which will be populated to the sequel adopter now make a simple check to see whether there is some data in the data table which can be done by checking the rows count [Music] if the result is 1 then it means our query check is successful and we can grant the user permission to our main dashboard as per below code we just show the main dashboard and hide the login form [Music] thanks for watching and I hope it was useful for you like and subscribe for more useful videos in future
Info
Channel: Teacher_Ali
Views: 34,498
Rating: undefined out of 5
Keywords:
Id: mF14hCeKkGs
Channel Id: undefined
Length: 13min 8sec (788 seconds)
Published: Sat Feb 29 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.