SlideShare a Scribd company logo
public partial class _Default : System.Web.UI.Page
{ SqlConnection con=new SqlConnection("Data Source=kol-11102-srvmr; Initial
Catalog=Student_s1; User ID = sa; Password = niit@123");
    protected void Page_Load(object sender, EventArgs e)
    {
         if (!IsPostBack)
             Student_Detail();
    }
    public void Student_Detail()
    {
         con.Open();
         SqlCommand cmd = new SqlCommand("select Student_Id from Student_Detail
", con);
         SqlDataAdapter ad = new SqlDataAdapter(cmd);
         DataTable dt = new DataTable();
         ad.Fill(dt);
         DropDownList1.Items.Clear();
         DropDownList1.DataSource = dt;
         DropDownList1.DataTextField = "Student_Id";
         DropDownList1.DataBind();

     }

    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=kol-11102-srvmr; Initial
Catalog=Student_s1; User ID = sa; Password = niit@123";
        con.Open();
        SqlCommand cmd = new SqlCommand("update Student_Detail set
S_Name='"+TextBox1.Text+"',Course='"+TextBox2.Text+"',Address='"+TextBox3.Text+"
',Phon_no='"+TextBox4.Text+"' where Student_Id='"+DropDownList1.Text+"'",con);
        cmd.ExecuteNonQuery();

     }
     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs
e)
     {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=kol-11102-srvmr; Initial
Catalog=Student_s1; User ID = sa; Password = niit@123";
        con.Open();
        SqlCommand cmd = new SqlCommand("select* from Student_Detail where
Student_Id ='" + DropDownList1.Text + "'", con);



          SqlDataReader dr = cmd.ExecuteReader();
          dr.Read();

          if (dr.HasRows)
          {
              TextBox5.Text = dr["Student_Id"].ToString();
              TextBox1.Text= dr["S_Name"].ToString();
              TextBox2.Text= dr["Course"].ToString();
              TextBox3.Text= dr["Address"].ToString();
              TextBox4.Text = dr["Phon_no"].ToString();


          }

      }

     protected void Button2_Click(object sender, EventArgs e)
{

        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=kol-11102-srvmr; Initial
Catalog=Student_s1; User ID = sa; Password = niit@123";
        con.Open();
        SqlCommand cmd = new SqlCommand("insert into Student_Detail
values('"+DropDownList1.Text+"','"+TextBox1.Text + "','" + TextBox2.Text + "','"
+ TextBox3.Text + "','" + TextBox4.Text + "')", con);
        cmd.ExecuteNonQuery();
        TextBox5.Text = "";
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=kol-11102-srvmr; Initial
Catalog=Student_s1; User ID = sa; Password = niit@123";
        con.Open();
        SqlCommand cmd = new SqlCommand("Delete Student_Detail where
Student_Id='" + DropDownList1.Text + "'", con);
        cmd.ExecuteNonQuery();
        TextBox5.Text = "";
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";
    }
    protected void Button4_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection();
        con.ConnectionString = "Data Source=kol-11102-srvmr; Initial
Catalog=Student_s1; User ID = sa; Password = niit@123";
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from Student_Detail where
Student_Id='" + DropDownList1.Text + "'", con);
        SqlDataAdapter ad = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        ad.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        TextBox5.Text = "";
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";

    }
}

More Related Content

What's hot (20)

PDF
Ajax chap 5
Mukesh Tekwani
 
PDF
Ajax chap 4
Mukesh Tekwani
 
PDF
Ajax chap 3
Mukesh Tekwani
 
PDF
Ajax chap 2.-part 1
Mukesh Tekwani
 
PPTX
MongoDB Aggregation
Amit Ghosh
 
PDF
droidQuery: The Android port of jQuery
PhDBrown
 
PPTX
SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx
MongoDB
 
PDF
Use Kotlin scripts and Clova SDK to build your Clova extension
LINE Corporation
 
PPTX
Javascript Execution Context Flow
kang taehun
 
PDF
What do you mean, Backwards Compatibility?
Trisha Gee
 
PDF
A evolução da persistência de dados (com sqlite) no android
Rodrigo de Souza Castro
 
PPTX
Javascript 2
pavishkumarsingh
 
PPTX
Engaging users with live tiles and notifications
Alex Golesh
 
PPTX
How to leverage what's new in MongoDB 3.6
Maxime Beugnet
 
PDF
GraphQL Bangkok Meetup 2.0
Tobias Meixner
 
PPTX
MongoDB - Aggregation Pipeline
Jason Terpko
 
PPTX
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
재춘 노
 
Ajax chap 5
Mukesh Tekwani
 
Ajax chap 4
Mukesh Tekwani
 
Ajax chap 3
Mukesh Tekwani
 
Ajax chap 2.-part 1
Mukesh Tekwani
 
MongoDB Aggregation
Amit Ghosh
 
droidQuery: The Android port of jQuery
PhDBrown
 
SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx
MongoDB
 
Use Kotlin scripts and Clova SDK to build your Clova extension
LINE Corporation
 
Javascript Execution Context Flow
kang taehun
 
What do you mean, Backwards Compatibility?
Trisha Gee
 
A evolução da persistência de dados (com sqlite) no android
Rodrigo de Souza Castro
 
Javascript 2
pavishkumarsingh
 
Engaging users with live tiles and notifications
Alex Golesh
 
How to leverage what's new in MongoDB 3.6
Maxime Beugnet
 
GraphQL Bangkok Meetup 2.0
Tobias Meixner
 
MongoDB - Aggregation Pipeline
Jason Terpko
 
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
재춘 노
 

Viewers also liked (12)

PDF
Distribución tetraédrica de los coeficientes de un tetranomio elevado a la m
Enrique Ramon Acosta Ramos
 
PPSX
Un saludo para todos y feliz carnal 2013
Claudio Laura C
 
PPTX
Tema 13
Marta Mengual
 
DOCX
BENGABY DOC
Benjamin Gabriel
 
PDF
Ghk2012 brochure
Kotra Kbc
 
PDF
ALEXIUM Template_v1
Sara Langridge
 
PDF
aft2
John Tomac
 
PPTX
Treatments
calandjess
 
TXT
Imapril2.
vampirelover3369
 
PPTX
Tech to build your omnichannel
Retail Pro International, LLC
 
Distribución tetraédrica de los coeficientes de un tetranomio elevado a la m
Enrique Ramon Acosta Ramos
 
Un saludo para todos y feliz carnal 2013
Claudio Laura C
 
Tema 13
Marta Mengual
 
BENGABY DOC
Benjamin Gabriel
 
Ghk2012 brochure
Kotra Kbc
 
ALEXIUM Template_v1
Sara Langridge
 
Treatments
calandjess
 
Imapril2.
vampirelover3369
 
Tech to build your omnichannel
Retail Pro International, LLC
 
Ad

Similar to Codeofdatabase (20)

DOCX
bai giai de LTWINForm.docx
VnThanh292761
 
TXT
New text document
Tam Ngo
 
TXT
Code
mimidas
 
TXT
Vb database connections
Tharsikan
 
PDF
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
GOKUL SREE
 
PDF
Ditec esoft C# project
K.K.T Madhusanka
 
PDF
Ditec esoft C# project
K.K.T Madhusanka
 
DOC
Quanlycanbo
PHUONGVINH
 
PPTX
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
PPTX
ONLINE STUDENT MANAGEMENT SYSTEM
Rohit malav
 
DOCX
Inventory program in mca p1
rameshvvv
 
PPTX
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
DOCX
Dotnet 18
dhruvesh718
 
PDF
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
PPTX
Java весна 2013 лекция 2
Technopark
 
TXT
Ss
Karan Soni
 
PDF
662305 09
Nitigan Nakjuatong
 
PPTX
Data and information about anatical subject
epfoportal69
 
PPTX
The sql connection object
Sharat Chandu
 
bai giai de LTWINForm.docx
VnThanh292761
 
New text document
Tam Ngo
 
Code
mimidas
 
Vb database connections
Tharsikan
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
GOKUL SREE
 
Ditec esoft C# project
K.K.T Madhusanka
 
Ditec esoft C# project
K.K.T Madhusanka
 
Quanlycanbo
PHUONGVINH
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
ONLINE STUDENT MANAGEMENT SYSTEM
Rohit malav
 
Inventory program in mca p1
rameshvvv
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
Dotnet 18
dhruvesh718
 
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
Java весна 2013 лекция 2
Technopark
 
Data and information about anatical subject
epfoportal69
 
The sql connection object
Sharat Chandu
 
Ad

Codeofdatabase

  • 1. public partial class _Default : System.Web.UI.Page { SqlConnection con=new SqlConnection("Data Source=kol-11102-srvmr; Initial Catalog=Student_s1; User ID = sa; Password = niit@123"); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) Student_Detail(); } public void Student_Detail() { con.Open(); SqlCommand cmd = new SqlCommand("select Student_Id from Student_Detail ", con); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); ad.Fill(dt); DropDownList1.Items.Clear(); DropDownList1.DataSource = dt; DropDownList1.DataTextField = "Student_Id"; DropDownList1.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=kol-11102-srvmr; Initial Catalog=Student_s1; User ID = sa; Password = niit@123"; con.Open(); SqlCommand cmd = new SqlCommand("update Student_Detail set S_Name='"+TextBox1.Text+"',Course='"+TextBox2.Text+"',Address='"+TextBox3.Text+" ',Phon_no='"+TextBox4.Text+"' where Student_Id='"+DropDownList1.Text+"'",con); cmd.ExecuteNonQuery(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=kol-11102-srvmr; Initial Catalog=Student_s1; User ID = sa; Password = niit@123"; con.Open(); SqlCommand cmd = new SqlCommand("select* from Student_Detail where Student_Id ='" + DropDownList1.Text + "'", con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); if (dr.HasRows) { TextBox5.Text = dr["Student_Id"].ToString(); TextBox1.Text= dr["S_Name"].ToString(); TextBox2.Text= dr["Course"].ToString(); TextBox3.Text= dr["Address"].ToString(); TextBox4.Text = dr["Phon_no"].ToString(); } } protected void Button2_Click(object sender, EventArgs e)
  • 2. { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=kol-11102-srvmr; Initial Catalog=Student_s1; User ID = sa; Password = niit@123"; con.Open(); SqlCommand cmd = new SqlCommand("insert into Student_Detail values('"+DropDownList1.Text+"','"+TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "')", con); cmd.ExecuteNonQuery(); TextBox5.Text = ""; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; } protected void Button3_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=kol-11102-srvmr; Initial Catalog=Student_s1; User ID = sa; Password = niit@123"; con.Open(); SqlCommand cmd = new SqlCommand("Delete Student_Detail where Student_Id='" + DropDownList1.Text + "'", con); cmd.ExecuteNonQuery(); TextBox5.Text = ""; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; } protected void Button4_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=kol-11102-srvmr; Initial Catalog=Student_s1; User ID = sa; Password = niit@123"; con.Open(); SqlCommand cmd = new SqlCommand("select * from Student_Detail where Student_Id='" + DropDownList1.Text + "'", con); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); TextBox5.Text = ""; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; } }