Here are some simple and easy methods to create a registration form and storing data in the database. First of all, you have to design a form by using your visual studio.net tool. There are some simple steps that will be helpful for you to create a form and storing data in the database.
Step-1: Create a simple form as shown below
Step-2: After completed your form designing process, now just create a table in your database. Make sure all the fields in the table are the same as you have added in the form
Step-3: These two steps are very important for developing but the most important step is the programming phase. which performs a connection between the database and design form. I am sure you have successfully completed these two steps, now just open the designing phase of the form and double click on submit button (as shown on the above web form demo) and write down the below code.
An important thing you have to remember in this source is, just change SqlConnection conn and write down your database path. here is my SQL connection path, you have to change this one and give your database path. (C:\USERS\AMIR\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\WEBSITE1\APP_DATA\KIU.MDF;)
SqlConnection conn = new SqlConnection(@”Data Source=.\SQLEXPRESS;AttachDbFilename=C:\USERS\AMIR\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\WEBSITE1\APP_DATA\KIU.MDF;Integrated Security=True;User Instance=True”);
cmd = new SqlCommand(“Select * from asp_staff Where first_name='” + txtfnme.Text + “‘”, conn);
reader = cmd.ExecuteReader();
txteadrs.Text = “”;
txtcnic.Text = “”;
txtfnme.Text = “”;
lblreg.Text = “**Dear Staff You have been already registered….! thanks for joining**”;
// lblstndreg.Text = “Dear Student you have already registered…..! thanks for joining”;
cmd = new SqlCommand(“Insert into asp_staff(first_name,last_name,email_address,password,confirm_password,qualification,gender,department,cnic,designition,address,contact_no) Values(‘” + txtfnme.Text + “‘,'” + txtlnme.Text + “‘,'” + txteadrs.Text + “‘,'” + txtpswrd.Text + “‘,'” + txtcpswrd.Text + “‘,'” + txtql.Text + “‘,'” + ddlgnder.Text + “‘,'” + ddldpt.Text + “‘,'” + txtcnic.Text + “‘,'” + txtdesgn.Text + “‘,'” + txtadrs.Text + “‘,'” +txtcntct.Text + “‘)”, conn);
//lblsgnup.Text = “Your account has been successfully created”;
This is the end of creating the registration form process and how to store data into the database. i am sure and hopefully, you will successfully create your registration form. Good luck. – 🙂