Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

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
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

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
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