C# Asp.Net - User Registration Or Sign Up With SQL Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up YouTube welcome to dotnet move in this video tutorial we will learn how to create user registration form in asp.net web form application before starting this video tutorial I would like to ask you a favor if you found this video helpful please thumbs up this video and for more hours and videos like this please be subscribed to this channel dotnet more without further explanation 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 new project thing here or go to file then new Zen project or you can use the shortcut ctrl shift can click on that in this dialog box select web under we should see shop then select we should Studio 2012 then select SP dotnet Web Application the name your project here I will name it as user registration from here select the location where you want to save this application then click on ok so here we have the brand-new asp.net web application before continuing with this closet we have to create database for this project for that let me switch to my management studio this is my management studio 2014 so here we have connected to SQL Server 2012 Express Edition now we have to create a new database for that right click on databases then click on new database now name your DB here I will name it as user registration DB then click on OK newly created database can be seen here user registration DB expanded now we have to create a new tab right click on tablets then tablet now we have to list columns for this table let me look my design here but so far we have forced name last name contact gender address username and password so in total we have 7 columns first of all first name as worker 50 then we have last name as work our 50 then we have contact as work f of B then we have gender as walk out 10 then we have address as work 250 then we have username and password username and soft the type what calf of P then password as well cup of tea finally I am going to add ID column for this table it will be user ID its optic type individual let me mark it as primary key now I want to use this same column as the identity specification for this table for that go to column properties then identity specifications set this as yes I want this user ID as the first column for that I can just drag this column here he wrote the save this table you can use the shortcut control s or you can click on the Save button here you can name your table here I will name it as user registration now click on OK in order to see the newly created tablet right click on this table then click on refresh as per user registration table design user ID is the identity specification for this tablet so we don't want to insert values into this user ID column SQL Server will take care of that it will start from one incremented by 1 upon your recording session now let me switch back to visual studio now we have to add an X px up front page into this application for that right-click on this application then add webform name your phone here I will name it as index then click on OK currently this form is empty we have to convert this form into this form design here we have label text box pair for these controls so I am going to start with a table tablet let me add a row here this double contains two columns and second column will have account span of 2 or span to first column will be a level and second column we will have a text box I'll be like this we have 1 2 3 4 5 6 7 8 so in total we have it was like this we need to add 7 goes for that let me copy this and paste in yellow - 7 times first 4 will be for first name so a level will be first name correspond a text box will be txt force name then last name corresponding text box will be txt lastly then we have contact corresponding text box txt conduct then gender for dunder instead of a text box we have a drop down for that I'm going to replace this test box with a drop down list but that open your group box here and I'm going to drag this program list here change drop-down ID to DD l gender now switch to design mode click on this right arrow then edit items here you can add items into this drop-down list for that we can add first item will be male then we will have female now click on OK switch to source after then that we have address address corresponding text box will be txt address for address instead of single line text box we have multi-line text box so I want to change this text move into multi-line after address we have a horizontal line for that let me add an extra line here t r TD for span will be 3 and we are going to add a natural element here let me look the design is it looks fine next we have username username corresponding text box will be txt username and we have password password txt password for password we have to set text mode as password then only TV show as tick mark for entered characters we have to add an extra line for control password Nikko P DS and pacing here txt confirm password finally you can add a submit button for that let me add a row here see our first column will be empty in the second column we will add a submit button call span to a speed button text will be sub which I do will be PT and submit let me switch to design mode instead of password we have to end our confirm password so let me change that into confirm password now after this upload button we have to add two levels one for success message and one for error message so let me copy this line from here and facing below that insert of this label is rock this button we have a level level X will be empty ID will be LDL surface message let me copy this Nabal from here and I'm basing here LDL error message and I'm going to set the foreground color for this success message as 3 and that of error message will be all right now finally we have to set mandatory fees for this forum for that I will add our astrick mark for this username and password switch to source and I'm going to add a level here with you sir - boss level X will be an Astra o'clock foreground color will be what we copied this aspect mark and pacing here with password suit design mode yes that's it so we have misspelled address spelling said let me switch to source then removing the extra s let me say this now I want to run this application for that again click on the start button here so here we have the user registration form decide now we can start writing c-sharp cooperating user decays into tab before that we have to write a stroke procedure for this operation but that let me switch to management studio in order to create a new store procedure right click on the database then click on new query you can start like this create row slow passenger may use add or edit then we can pass parameters for this row procedure that let me copy column names from here and paste here we want to add a do it symbol before these column names for the and hold ctrl then track along the left side of this editor then insert the symbol at the weight is the IDS of the guide integer then we have forced meme as worker 50 let me copy this from here and pissing below that because all of them have same that I typed gender is of the type work at them then to address 250 username and password in this procedure we are going to do two operation insert and edit operation if fi ID is equal to zero then we will go for insert operation in the else part we will update the user code insert impotent user registration then we have to pass column names for that let me copy this column names from here and paste you you don't want to integrate this into this user ID column SQL server will take care of that if you start from one and incremented by 1 upon your Court in session so let me get rid of this user ID column then forced me to a coma then last name now we want to pass values into this column for that values let me copy these column names from here and paste here put at the rate symbol here in the s part given Budi update operation engaged in serving station sets let me copy these column names from here and pacing here first name is equal to at the rate first name you world user ID is equal to FDA is ID in order to create the stored procedure click on this execute button here will equate the slow passenger can be seen under store procedures here now we have to add one more store procedure for that I peak on the database then click on new query create cause stroke acetal name will be user view stop azalea name will be user view by ID we have one parameter user ID as integer as then we can write our query here select star from users registrations both user ID this ID is equal to given user ID let's in order to create this toe procedure click on this execute button here now let me switch back to my studio in order to implement insert or update operation movable using button click even of submit button to generate the even double click on this button so here we have the submit button click event now we can start writing C shop code here first of all I will declare a string variable to store the connection string add inside double course we have to pass connection string for this database so let me paste my connection string here now let me zoom this editor here we have imported two namespaces system dot data dot a secured line and system dot data now we can start with using statement here I will declare SQL connection on the teo scale connection access your corn equals previous scale connection and here we need to pass conscious string then we can open the connection here by calling the function over you know that you can write code for calling the stored procedure in c-sharp using statement is a best practice to interact with database because we don't want to close this SQL connection at the end of this statement and if there is any error in between these lines of execution using statement will close this connection first of all I am going to declare SQL command object here SQL commands as SQL see MD equals the SQL command key we need to pass the circle CTO megazor ad already let me copy this and paste it here as a second parameter you pass this here with caution objects now we need to set the command type for this objects qlc MV dot command type equals command type dot store the schedule now we have to pass values for parameters in this top procedure for that SQL CMD dot parameters parameters doors and with values as a first parameter will pass the parameter name the ID and then we have to pass the value from hidden field I think we have not added the hidden field for that SP hidden fields' ID equal to X F choose the ID I use H of as a prefix for hidden field run ad server flat now we can pause values for user ID from the hidden feet convert to in 32 H F is the ID dot value if hidden field value is empty strings then we will pass 0 otherwise we'll pass the hidden field itself below that we have to pass values for remaining parameters for that let me copy this antigen below that then we have force name firstly we will pass value from the txt first name text box text dot trim trim function is used to remove spaces from both ends like this we have to pass 6 more parameters for that let me copy this and paste in below that six times after first name we have last name let me paste that here instead of txt first name we have txt last name then we have contact since gender is a text box we can pass values like this dbl then the dot selected value you that's it now we need to execute this top procedure for that is clear CMD thought execute don't parry now we will set the status message LBL success message dot text equals submitted successfully after insert or update operation we have to clear these form elements for that let me declare another function void clear first of all we will clear text boxes txt first name dot text equals txt last name dot txt you equals txt confirm password not text equals empty string let me hide this solution Explorer so here we have cleared all the text boxes now we have to clear the hidden field edge F user ID dot value equals empty string after that we nuclear notification labels lbs circles message store text equals LBL error message dot text equals cutie string now I want to call this function here okay before this insert or update operation we have to check whether mandatory fields are entered or not after that we have to check whether these password and confirm password match each other for that I am going to use if-else log here first of all we will check mattify's takes the username dot text equals empty string or txt passwords dot text equals empty strings we will set the error message LBL error message dot text equals please fill mandatory fields after that we will check whether confirm password and password expand switch each other if txt password dot text not equal to TX t confirm password dot Tex then we will set the error message ABL thermoses dot text password password Denault max in the else part we will do the insert or update operation now inside the page load event we will call the clear function if it is not a post back is post back then we recall clear function course inside this if block will be executed when the page is loaded for the first time after that there might be some server-side events using that events page load will be called but course inside this if block will not be executed now let me run this application for that you can click on the start button here now let me test the validation of this form I am going to submit this form without entering any fields click on submit so here we have the error message please fill mandatory fields then I am going to end the different password here 1 2 3 3 2 1 password do not match so validation for this form is working now let me enter some test data into this form Smith John one two three click on submit so here we can see the success message let me check my table right click on the table then select Oh Towson goes newly added user details can be seen here now we are going to do the edit or update operation for update operation I am going to use query string ID if now taper too strong is null or empty inside that will pass the query string request dot query string ID so if query string ID is not equal to null or empty we will execute this if block now I am going to declare an integer variable here user ID is equal to convert to spoon 32 inside that I will pass this query string let me copy that and paste in here then I am going to start with using statement inside that I will declare SQL connection objects as SQL code equals muisc URL connection beside that I will pass it on some string let me open this ql connection here your phone dot open now let me be clear SQL data adapter as SQL da equals new SQL data adapter inside then we will pass this locus is your name let me copy this from here and pasting here the second parameter we will pass this function object me of SQL da dot select command dot command type equals command type dot store procedure so this store procedure we have one parameter so class value for that parameter select command broad parameters dot add with value let me copy parameter name from here and paste in here then I will pause the user ID here so ID then I am going to declare that a double here that are doubled as DT D l equals M data table and I am going to execute this stupid feature SQL the air dot fills so we will retrieve the details into this data table so inside this tag a tablet we have details of use of with given ID now we want to fill these details into these form controls for that first of all we have hidden field H F user ID dot value equals user ID to string then we have first name txt first name dot x equals d TBL rows first row so index will be 0 first name is the second coil so column index will be point to string like this we have one two three four five six seven seven keys are remaining now let me copy this line and piecing below Jack several times txt last name corresponding column index will be 2 then TX key contacts corresponding column index will be 3 then we have got down list you know to set the drop-down selector value TTL gendered all items dot find by value then pass gender column here let me copy this and pacing here instead of three we have four dot selected equals true when we have txt address corresponding column index will be five they may have username txt user link corresponding column index will be six then we have txt password corresponding column index will be seven now we have one more text box for confirm password for that let me get rid of this extra line and I'm going to copy this and paste in hello is that instead of txt password we have txt confirm password in order to set values for password fields we have to do one more thing txt password dot attributes dot add value then we will pass this value from here and paste in here now we have to do the same operation for txt confirm password also txt confirm password let me on this application for that you can click on the start button here now I want to edit this record is a ID which one for that I can pass query string here question mark ID is equal to one so I will fill the details of user with user ID one in these form elements now I want to check this first name into a slick one shown one let me edit these address here updated updated address now click on submit so here you can see the success message let me check my dB now execute this query again for that click on this execute button here so here you can see that user with user ID is updated with you because that's it if you found this video helpful please please subscribe to this channel Gordon AdMob you can download this project source code and liddy script from the link given below in video description we have already discussed how to implement coke operations in asp.net web form a platoon using SQL Server you can find the video link in video description please like and share this video with your friends and colleagues so that they can benefit from this have a nice day bye
Info
Channel: CodAffection
Views: 128,762
Rating: 4.8764477 out of 5
Keywords: User Registration in C# Asp.Net, How to Create User Registration Form in Asp.net Web Form, With SQL Server Database, Sign Up in Asp.Net, with storedprocedure, User Registration Insert and Update, User Registration Form Validation, asp.net tutorial for beginners, Design user registration form in asp.net, registration form in asp.net with database, asp.net registration form using c#, c# sql server register, how to make a sign up page using sql server and asp.net, CodAffection
Id: CsT1G3SmHXE
Channel Id: undefined
Length: 33min 21sec (2001 seconds)
Published: Mon Jul 10 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.