Here are some simple and easy methods to create a registration form and storing data in 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 into 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 same as you have added in the form.
Step-3: These two steps are very important for developing but the most important step is programming phase. which performs a connection between database and design form. I am sure you have successfully completed these two steps, now just open designing phase of the form and double click on submit button (as shown on the above web form demo) and write down 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 registration form process and how to store data into database. i am sure and hopefully you will successfully created your registration form. Gud luck. – 🙂