Resources » Code Snippets » ASP.NET WebForms

A simple registration form


Posted Date: 14-Sep-2009  Last Updated:   Category: ASP.NET WebForms    
Author: Member Level: Gold    Points: 10



A Simple registration form


create a registration table in sql2005
sql query

CREATE TABLE [dbo].[MemberRegistration](
[MemberName] [varchar](40) ,
[DOB] [varchar](40) ,
[FatherName] [varchar](40),
[Occupation] [varchar](40),
[Address] [varchar](200),
[Country] [varchar](40),
[State] [varchar](40),
[City] [varchar](40),
[Phone] [varchar](40),
[Pincode] [varchar](40),
[Mobile] [varchar](40),
[Email] [varchar](40),
[Qualification] [varchar](40),
[InstituteName] [varchar](40),
[Subject] [varchar](40),
[SkillSet] [varchar](100),
[Programming_Languages] [varchar](300),
[Databases] [varchar](40),
[WebServer] [varchar](40),
[MemberID] [bigint] IDENTITY(1000,1) NOT NULL,
PRIMARY KEY CLUSTERED
(
[MemberID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]



Create a registration.aspx page which contains all the fields present in the above Query

Drag a button and rename to SUBMIT
Double click on SUBMIT button to get registartion.aspx.cs

Under button click event write below code

protected void btnSubmit_Click(object sender, EventArgs e)
{
con.Open();

cmd = new SqlCommand("InsertMember", con);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("@Name", SqlDbType.VarChar, 40);
cmd.Parameters["@Name"].Value = txtMemberName.Text;

cmd.Parameters.Add("@SponserID", SqlDbType.BigInt);
cmd.Parameters["@SponserID"].Value = Convert.ToInt32(txtSponsorId.Text);

cmd.Parameters.AddWithValue("@initial_amt", Amount);

cmd.Parameters.Add("@DOB", SqlDbType.VarChar, 40);
cmd.Parameters["@DOB"].Value = txtDob.Text;

cmd.Parameters.Add("@FatherName", SqlDbType.VarChar, 40);
cmd.Parameters["@FatherName"].Value = txtFathersName.Text;

cmd.Parameters.Add("@Occupation", SqlDbType.VarChar, 40);
cmd.Parameters["@Occupation"].Value = txtOccupation.Text;

cmd.Parameters.Add("@Address", SqlDbType.VarChar, 200);
cmd.Parameters["@Address"].Value = txtAddress1.Text;

cmd.Parameters.Add("@Country", SqlDbType.VarChar, 40);
cmd.Parameters["@Country"].Value = ddlCountry.SelectedValue;

cmd.Parameters.Add("@State", SqlDbType.VarChar, 40);
cmd.Parameters["@State"].Value = ddlState.SelectedValue;

cmd.Parameters.Add("@City", SqlDbType.VarChar, 40);
cmd.Parameters["@City"].Value = ddlCity.SelectedValue;

cmd.Parameters.Add("@Phone", SqlDbType.VarChar, 40);
cmd.Parameters["@Phone"].Value = txtPhone.Text;

cmd.Parameters.Add("@Pincode", SqlDbType.VarChar, 40);
cmd.Parameters["@Pincode"].Value = txtPincode.Text;

cmd.Parameters.Add("@Mobile", SqlDbType.VarChar, 40);
cmd.Parameters["@Mobile"].Value = txtMobile.Text;

cmd.Parameters.Add("@Email", SqlDbType.VarChar, 40);
cmd.Parameters["@Email"].Value = txtEmail.Text;

cmd.Parameters.Add("@Qualification", SqlDbType.VarChar, 40);
cmd.Parameters["@Qualification"].Value = txtQualification.Text;

cmd.Parameters.Add("@InstituteName", SqlDbType.VarChar, 40);
cmd.Parameters["@InstituteName"].Value = txtInstituteName.Text;

cmd.Parameters.Add("@Subject", SqlDbType.VarChar, 40);
cmd.Parameters["@Subject"].Value = txtSubject.Text;

cmd.Parameters.Add("@SkillSet", SqlDbType.VarChar, 100);
cmd.Parameters["@SkillSet"].Value = txtSkillset.Text;

cmd.Parameters.Add("@Programming_Languages", SqlDbType.VarChar, 300);
cmd.Parameters["@Programming_Languages"].Value = txtProgramlanguage.Text;

cmd.Parameters.Add("@Databases", SqlDbType.VarChar, 40);
cmd.Parameters["@Databases"].Value = txtDatabase.Text;

cmd.Parameters.Add("@WebServer", SqlDbType.VarChar, 40);
cmd.Parameters["@WebServer"].Value = txtWebServer.Text;

cmd.Parameters.Add("@MemberID", SqlDbType.BigInt);
cmd.Parameters["@MemberID"].Direction = ParameterDirection.Output;

cmd.ExecuteNonQuery();
con.Close();



}



now you can debugg the code.Run the code and insert each field values.


Did you like this resource? Share it with your friends and show your love!

Responses to "A simple registration form"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Bahram Noghrey
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India