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

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

What's hot (20)

Kode
KodeKode
Kode
 
Ajax chap 5
Ajax chap 5Ajax chap 5
Ajax chap 5
 
Ajax chap 4
Ajax chap 4Ajax chap 4
Ajax chap 4
 
Ac2
Ac2Ac2
Ac2
 
Ajax chap 3
Ajax chap 3Ajax chap 3
Ajax chap 3
 
Ajax chap 2.-part 1
Ajax chap 2.-part 1Ajax chap 2.-part 1
Ajax chap 2.-part 1
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQuery
 
SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx
SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptxSH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx
SH 1 - SES 7 - Change-Streams-Tel-Aviv.pptx
 
Use Kotlin scripts and Clova SDK to build your Clova extension
Use Kotlin scripts and Clova SDK to build your Clova extensionUse Kotlin scripts and Clova SDK to build your Clova extension
Use Kotlin scripts and Clova SDK to build your Clova extension
 
Javascript Execution Context Flow
Javascript Execution Context FlowJavascript Execution Context Flow
Javascript Execution Context Flow
 
What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?What do you mean, Backwards Compatibility?
What do you mean, Backwards Compatibility?
 
A evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no androidA evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no android
 
Javascript 2
Javascript 2Javascript 2
Javascript 2
 
Engaging users with live tiles and notifications
Engaging users with live tiles and notificationsEngaging users with live tiles and notifications
Engaging users with live tiles and notifications
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation PipelineMongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
 
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
 
C#
C#C#
C#
 

Viewers also liked

Distribución tetraédrica de los coeficientes de un tetranomio elevado a la m
Distribución tetraédrica de los coeficientes de un tetranomio elevado a la  mDistribución tetraédrica de los coeficientes de un tetranomio elevado a la  m
Distribución tetraédrica de los coeficientes de un tetranomio elevado a la m
Enrique Ramon Acosta Ramos
 
Adana Valisi Buyukten Abtuye Ziyaret
Adana Valisi Buyukten Abtuye ZiyaretAdana Valisi Buyukten Abtuye Ziyaret
Un saludo para todos y feliz carnal 2013
Un saludo para todos y feliz carnal 2013Un saludo para todos y feliz carnal 2013
Un saludo para todos y feliz carnal 2013
Claudio Laura C
 
Ghk2012 brochure
Ghk2012 brochureGhk2012 brochure
Ghk2012 brochure
Kotra Kbc
 
Mat 11 u1
Mat 11 u1Mat 11 u1
Tech to build your omnichannel
Tech to build your omnichannelTech to build your omnichannel
Tech to build your omnichannel
Retail Pro International, LLC
 

Viewers also liked (12)

Distribución tetraédrica de los coeficientes de un tetranomio elevado a la m
Distribución tetraédrica de los coeficientes de un tetranomio elevado a la  mDistribución tetraédrica de los coeficientes de un tetranomio elevado a la  m
Distribución tetraédrica de los coeficientes de un tetranomio elevado a la m
 
Adana Valisi Buyukten Abtuye Ziyaret
Adana Valisi Buyukten Abtuye ZiyaretAdana Valisi Buyukten Abtuye Ziyaret
Adana Valisi Buyukten Abtuye Ziyaret
 
Un saludo para todos y feliz carnal 2013
Un saludo para todos y feliz carnal 2013Un saludo para todos y feliz carnal 2013
Un saludo para todos y feliz carnal 2013
 
Tema 13
Tema 13Tema 13
Tema 13
 
BENGABY DOC
BENGABY DOCBENGABY DOC
BENGABY DOC
 
Ghk2012 brochure
Ghk2012 brochureGhk2012 brochure
Ghk2012 brochure
 
ALEXIUM Template_v1
ALEXIUM Template_v1ALEXIUM Template_v1
ALEXIUM Template_v1
 
aft2
aft2aft2
aft2
 
Treatments
TreatmentsTreatments
Treatments
 
Imapril2.
Imapril2.Imapril2.
Imapril2.
 
Mat 11 u1
Mat 11 u1Mat 11 u1
Mat 11 u1
 
Tech to build your omnichannel
Tech to build your omnichannelTech to build your omnichannel
Tech to build your omnichannel
 

Similar to Codeofdatabase

bai giai de LTWINForm.docx
bai giai de LTWINForm.docxbai giai de LTWINForm.docx
bai giai de LTWINForm.docx
VnThanh292761
 
New text document
New text documentNew text document
New text document
Tam Ngo
 
Vb database connections
Vb database connectionsVb database connections
Vb database connections
Tharsikan
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
GOKUL SREE
 
Ditec esoft C# project
Ditec esoft C# project Ditec esoft C# project
Ditec esoft C# project
K.K.T Madhusanka
 
Ditec esoft C# project
Ditec esoft C# projectDitec esoft C# project
Ditec esoft C# project
K.K.T Madhusanka
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
ONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEMONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEM
Rohit malav
 
Inventory program in mca p1
Inventory program in mca p1Inventory program in mca p1
Inventory program in mca p1rameshvvv
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
SaraswathiRamalingam
 
How to Create Database component -Enterprise Application Using C# Lab
How to Create Database component -Enterprise Application Using C# Lab  How to Create Database component -Enterprise Application Using C# Lab
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2Technopark
 
662305 09
662305 09662305 09
The sql connection object
The sql connection objectThe sql connection object
The sql connection objectSharat Chandu
 
Simple.Data intro slides
Simple.Data intro slidesSimple.Data intro slides
Simple.Data intro slides
Mark Rendle
 

Similar to Codeofdatabase (20)

bai giai de LTWINForm.docx
bai giai de LTWINForm.docxbai giai de LTWINForm.docx
bai giai de LTWINForm.docx
 
New text document
New text documentNew text document
New text document
 
Code
CodeCode
Code
 
Vb database connections
Vb database connectionsVb database connections
Vb database connections
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
Ditec esoft C# project
Ditec esoft C# project Ditec esoft C# project
Ditec esoft C# project
 
Ditec esoft C# project
Ditec esoft C# projectDitec esoft C# project
Ditec esoft C# project
 
Quanlycanbo
QuanlycanboQuanlycanbo
Quanlycanbo
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
ONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEMONLINE STUDENT MANAGEMENT SYSTEM
ONLINE STUDENT MANAGEMENT SYSTEM
 
Inventory program in mca p1
Inventory program in mca p1Inventory program in mca p1
Inventory program in mca p1
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
How to Create Database component -Enterprise Application Using C# Lab
How to Create Database component -Enterprise Application Using C# Lab  How to Create Database component -Enterprise Application Using C# Lab
How to Create Database component -Enterprise Application Using C# Lab
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
Ss
SsSs
Ss
 
662305 09
662305 09662305 09
662305 09
 
Borrar
BorrarBorrar
Borrar
 
The sql connection object
The sql connection objectThe sql connection object
The sql connection object
 
Simple.Data intro slides
Simple.Data intro slidesSimple.Data intro slides
Simple.Data intro slides
 

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 = ""; } }