0% found this document useful (0 votes)
24 views2 pages

Using Using Using Using Using Using Using Using Using Using Using Using Public Partial Class

The document contains C# code for student registration using a SQL database. It defines a SqlConnection and initializes it with connection string parameters. It then defines event handler methods for page load and a submit button click. On page load, it populates dropdown lists. On submit button click, it opens the connection, defines a stored procedure command, adds parameter values from form fields, executes it to insert a record, displays a success message and redirects to the default page.

Uploaded by

Rajesh Dhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Using Using Using Using Using Using Using Using Using Using Using Using Public Partial Class

The document contains C# code for student registration using a SQL database. It defines a SqlConnection and initializes it with connection string parameters. It then defines event handler methods for page load and a submit button click. On page load, it populates dropdown lists. On submit button click, it opens the connection, defines a stored procedure command, adds parameter values from form fields, executes it to insert a record, displays a success message and redirects to the default page.

Uploaded by

Rajesh Dhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

con = new SqlConnection("initial catalog=college; integrated

security=true;data source=localhost");
con.Open();

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Windows.Forms;
public partial class Registration : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection("initial catalog=college; integrated
security=true;data source=localhost");
// con.Open();
if (!IsPostBack)
{
ddlcity.Items.Add("Chennai");
ddlcity.Items.Add("Coimbatore");
ddlcity.Items.Add("Madurai");
ddlcity.Items.Add("Trichy");
ddlcity.Items.Add("Salem");
ddlcity.Items.Add("Erode");
ddlcity.Items.Add("Tirunelveli");
ddlcity.Items.Add("Tutucorian");
}
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("sp_regis", con);
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@regid", txtregid.Text);
cmd.Parameters.AddWithValue("@collegename", txtcollege.Text);
cmd.Parameters.AddWithValue("@community", txtcommunity.Text);
cmd.Parameters.AddWithValue("@firstname", txtfirstname.Text);
cmd.Parameters.AddWithValue("@lastname", txtlastname.Text);
cmd.Parameters.AddWithValue("@username",txtuname.Text);

cmd.Parameters.AddWithValue("@password", txtpassword.Text);
cmd.Parameters.AddWithValue("@gender",
rdblist.SelectedItem.Text);
cmd.Parameters.AddWithValue("@dob", txtdob.Text);
cmd.Parameters.AddWithValue("@address", txtaddress.Text);
cmd.Parameters.AddWithValue("@city",ddlcity.SelectedItem.Text);
cmd.Parameters.AddWithValue("@mobile",txtmobile.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Registered Successfully");
txtregid.Text = "";
txtcollege.Text = "";
txtfirstname.Text = "";
txtlastname.Text = "";
txtuname.Text = "";
txtpassword.Text = "";
txtdob.Text = "";
txtaddress.Text = "";
txtmobile.Text = "";
rdblist.Enabled = false;
Response.Redirect("Default.aspx");

}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy