C# - Create User Registration Or Sign Up Form With SQL Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up YouTube welcome to dotnet mom in this video I will show you how to design and implement user registration or signup form in c-sharp if you found this video helpful please thumbs up this video and for more hours of videos like this please please subscribe to this channel dot that mob without further ado let's get started this is my Visual Studio 2013 now we have to create a new project for that you can click on this link here or go to file then new then project or you can use the shortcut ctrl shift and click on that under we show C sharp select windows then windows form application name your project here I will name it as user registration then select the location where you want to save this application then click on OK now we have the brand-new windows form application it comes with a default form form one inside this form we have to design our form controls like this as per the given design we have 1 2 3 4 5 6 7 so in total we have 7 label Xbox pal let me add that for then go to view then click on toolbox first of all I am going to add a level here double click on it then we have a text box now arrange them in a same line like this we need 6 more paste for that select all of them then hold ctrl and drag them below like this before the last 3 text box label pair we have a horizontal line for that I will use a level here for that copy this level hold ctrl and drag or I click on the labels and properties then change I'll text with a sequence of underscores that's it so here we have the horizontal line now we need to name these controls and text boxes and we can do later now we need to add one button for that double click on button here then drag them into the place we have to change this form title for that I click on the form then properties change this into user registration or sign up that's it for now I will post this recording we can continue after arranging and naming these controls boom now we have a decent-looking user registration form like this first of all I have changed these form controls phone into cg.o UI 12 PT then change these labels text according to the given design then name these text boxes as txt force name txt last name txt corn back then txt address this text box is multi-line for that you have to click on this right arrow and check this multi-line check box then we have txt user name then we have password then txt confirm password finally change this button text to submit now we have to name this control as BT and submit finally we have to mark mandatory fees for this user registration form for that I will use a red colored plastic mark for that let me copy this label hold ctrl then drag change text to a stick mark change foreground color to red the whole control then drag them into password text box that's it so these two fields username and password are mandatory for this form now before continuing with this project we have to create SQL Server database for that let me switch to management studio first of all we have to create a new database for that right click on databases then new database the name you leave you here I will name it as user registration DB then click on OK newly created database can be seen here inside that we have to create a new table for that right click on tables then tab now we have to list columns for this table here first of all we have user ID as integer then we have first name as walk out 50 and we have last name as walk out 50 then we have conduct as work out 50 then we have address as walk up to 50 then we have user name username as walk out 50 then we have password as walk 50 now I want to set this user ID column as the primary key for that right-click on it and click on set primary key now I want to set this same column as the identity specification for this table for that go to column properties then expand identity specification then set this as yes so we don't want to insert values into user ID column SQL Server will take care of that if you start from one and incremented by 1 upon new recording session now in order to save this table you can use the shortcut control s or you can click on the Save button here name your table here TBL user click on OK you will create a table can be seen under tables now you have to create a new stored procedure for that right-click on the database then click on new query in order to create a new store procedure you can start like this create course info use add then here we have to leave parameters for the store procedure for that let me copy these column names from here and pacing here before store procedure parameter we have to add at the rate symbol for that I'm going to use a shortcut hold alt then drag along the left side of this editor then press add the weight symbols now we need to pass data type for this user ID in the first name as walk f of T now let me copy this and pasting here since they have same data type address as 250 and we have username and password insert into TBL user then we have to pass column list for this table for that let me copy these column names from here and paste in here you don't want this user ID since it is a identity specification column remove that the first name put a comma here the last name contact address user name and password and we have to pass values for that let me copy these column names from here and paste them here now we need to put a Dirac symbol here in order to create the stored procedure click on this execute button here is a add store procedure is created successfully you can see the newly created stored procedure and the store procedures you saw add now back to visual studio now we are going to do with the insert operation of these details into TBL user inside the submit button click event in order to generate the event double click on this submit button so here we have the submit button click event now let me declare a string variable connection string to store the connection string of user registration DB for now I will paste my connection string here so we have to import the namespace system dot data dot s clear client now inside the submit button click events you can start with using statement a service source we will declare SQL connection object here LCpl for equals new SQL connection inside that you will pass connection string for the database inside that you open this connection using the open function below that we can write code for calling this taupe procedure in c-sharp using statement is a best practice to interact with databases because we don't want to cause a skewer connection at the end of using statement and if there is any error in between these lines of execution using statement will close the connection now let me declare SQL command object here SQL command as SQL CMD equals you SQL command first parameter will be the stroke procedure name itself let me copy this stroke acedia name user add from here and basing here as a second parameter we have to pass this your connection object now we need to set command type for this object SQL c MV dot command type equals command type dot store procedure now we have to pass parameters value for the slope of C the cucm the doors parameters got add this value first of all we have first of all we have first name we don't need this user ID let me get rid of this user ID then change this create to alter then click on execute let me copy this first name from here and paste in here and we will pass this parameter value from first name cashbox dot text dot trim trim function is used to remove space from both ends like this we need to pass values for 5 parameters for that let me paste this 5 times here then last name then we have contact then address then we have user name then we have password txt last name txt contact then we have txt address txt username and tht password finally we are going to execute this toe procedure for that SQL CMD dot execute non carry after insert operation we have to clear these form elements for that I am going to declare a new function here void player now we have to play all these text boxes TXE force name dot text equals txt last name salt text you password or text equals empty string now we can call this clear function here before that we will show the message box dot show registration case success for it sorry here we have to clear confirm password also txt confirm password dot text equals empty string before this insert operation we have to check whether mandatory fields like is the name and password are filled or not after that we have to check whether this password and confirm password match with each other for that I am going to add if/else block here if txt username dot text equals empty strings of txt password dot text equals empty string then we will show this error message message box dot show please fill mandatory fields and if txt password dot text not equal to TX T confirm password dot text then maybe show the message passwords do not match password do not match in the else part we will do the insula operation that's it now let me run this application for that you can click on the start button here now let me test the magnetic fields for that I am going to submit this form without entering any field click on submit so it shows the message please field magnetic fields now I can fill this magnetic phase but passwords are not matching click on submit password do not match if you want to hide these characters from password text boxes as a sequence of a stick mark you can do that here right click on password text box and go to properties then set this password care as hash tick mark now I am going to enter some test data Co Smith password s one two three one two three click on submit so it shows the successful message let me check my DB for that right click on the tablet then click on select top thousand rows so here you can see the submitted data as the first record that's it guys if you found this video helpful please do subscribe to this channel dotnet MO you can download this project source code and d discrete from the link given below in video description please like and share this video with your friends and colleagues so that they can benefit from the have a nice day bye
Info
Channel: CodAffection
Views: 207,832
Rating: 4.8104448 out of 5
Keywords: How to create user registration form in c#, How to design user registration form in c#, Create Sign Up Form in c#, In Windows Form Application, User Registration Form, Using SQL Server Database, Using Stored procedure, c# insert or add user, form validation in c#, windows form tutorial, sign up form in c#, c# registration form, c# sign up form, registration form in c# with database, registration form in c#, CodAffection
Id: hxOB5ALWQMQ
Channel Id: undefined
Length: 17min 49sec (1069 seconds)
Published: Tue Jul 11 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.