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

    }
}
Ad

Recommended

syed
syed
Syed Mohd Naqi Zaidi
 
Ken 20150306 心得分享
Ken 20150306 心得分享
LearningTech
 
Id32
Id32
sandhish
 
Cnam azure 2014 mobile services
Cnam azure 2014 mobile services
Aymeric Weinbach
 
37c
37c
Sireesh K
 
Vb Project ขั้นเทพ
Vb Project ขั้นเทพ
Sinchai Lanon
 
Fetch data from form
Fetch data from form
Shahriar Malik
 
Ensure code quality with vs2012
Ensure code quality with vs2012
Sandeep Joshi
 
Kode
Kode
darwin sihaloho
 
Ajax chap 5
Ajax chap 5
Mukesh Tekwani
 
Ajax chap 4
Ajax chap 4
Mukesh Tekwani
 
Ac2
Ac2
Muhammad Islahuddin
 
Ajax chap 3
Ajax chap 3
Mukesh Tekwani
 
Ajax chap 2.-part 1
Ajax chap 2.-part 1
Mukesh Tekwani
 
MongoDB Aggregation
MongoDB Aggregation
Amit Ghosh
 
droidQuery: 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.pptx
MongoDB
 
Use 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 Flow
kang taehun
 
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 android
Rodrigo de Souza Castro
 
Javascript 2
Javascript 2
pavishkumarsingh
 
Engaging 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.6
Maxime Beugnet
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
Tobias Meixner
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
Jason Terpko
 
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
재춘 노
 
C#
C#
Armando Gonzalez
 
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 m
Enrique Ramon Acosta Ramos
 
Adana Valisi Buyukten Abtuye Ziyaret
Adana Valisi Buyukten Abtuye Ziyaret
Adana Klima Servisi Bakım Montaj Taşıma Temizlik Tamir Arıza Teknik Servisleri
 

More Related Content

What's hot (20)

Kode
Kode
darwin sihaloho
 
Ajax chap 5
Ajax chap 5
Mukesh Tekwani
 
Ajax chap 4
Ajax chap 4
Mukesh Tekwani
 
Ac2
Ac2
Muhammad Islahuddin
 
Ajax chap 3
Ajax chap 3
Mukesh Tekwani
 
Ajax chap 2.-part 1
Ajax chap 2.-part 1
Mukesh Tekwani
 
MongoDB Aggregation
MongoDB Aggregation
Amit Ghosh
 
droidQuery: 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.pptx
MongoDB
 
Use 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 Flow
kang taehun
 
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 android
Rodrigo de Souza Castro
 
Javascript 2
Javascript 2
pavishkumarsingh
 
Engaging 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.6
Maxime Beugnet
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
Tobias Meixner
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
Jason Terpko
 
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
재춘 노
 
C#
C#
Armando Gonzalez
 
MongoDB Aggregation
MongoDB Aggregation
Amit Ghosh
 
droidQuery: 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.pptx
MongoDB
 
Use 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 Flow
kang taehun
 
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 android
Rodrigo de Souza Castro
 
Engaging 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.6
Maxime Beugnet
 
GraphQL Bangkok Meetup 2.0
GraphQL Bangkok Meetup 2.0
Tobias Meixner
 
MongoDB - Aggregation Pipeline
MongoDB - Aggregation Pipeline
Jason Terpko
 
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
재춘 노
 

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 m
Enrique Ramon Acosta Ramos
 
Adana Valisi Buyukten Abtuye Ziyaret
Adana Valisi Buyukten Abtuye Ziyaret
Adana Klima Servisi Bakım Montaj Taşıma Temizlik Tamir Arıza Teknik Servisleri
 
Un saludo para todos y feliz carnal 2013
Un saludo para todos y feliz carnal 2013
Claudio Laura C
 
BENGABY DOC
BENGABY DOC
Benjamin Gabriel
 
Ghk2012 brochure
Ghk2012 brochure
Kotra Kbc
 
Treatments
Treatments
calandjess
 
Imapril2.
Imapril2.
vampirelover3369
 
Mat 11 u1
Mat 11 u1
Roxana Abarca Gonzalez
 
Tech to build your omnichannel
Tech to build your omnichannel
Retail Pro International, LLC
 
Ad

Similar to Codeofdatabase (18)

DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
GOKUL SREE
 
Code
Code
mimidas
 
How to Create Database component -Enterprise Application Using C# Lab
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
Vb database connections
Vb database connections
Tharsikan
 
Sql server query collection
Sql server query collection
Rabin Koirala
 
Public class form1
Public class form1
Sandra Aguirre
 
Public class form1
Public class form1
Sandra Aguirre
 
SQLite with UWP
SQLite with UWP
Cheah Eng Soon
 
Xml
Xml
polemsreedeep
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
Yosselin Marquez
 
76.pptx ajx ppt file for univercity of granted
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
Sql plsql
Sql plsql
prudhviraj_cse
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
Elizita Aguila Peralta
 
School System C# Code
School System C# Code
Paul Smyth
 
Application of Insert and select notes.ppt x
Application of Insert and select notes.ppt x
doxafo4842
 
Documento de altas
Documento de altas
alejandroDFK
 
ADO DOT NET
ADO DOT NET
Salman Mushtaq
 
Codes
Codes
OSit3
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
GOKUL SREE
 
How to Create Database component -Enterprise Application Using C# Lab
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
Vb database connections
Vb database connections
Tharsikan
 
Sql server query collection
Sql server query collection
Rabin Koirala
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
Yosselin Marquez
 
76.pptx ajx ppt file for univercity of granted
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
Elizita Aguila Peralta
 
School System C# Code
School System C# Code
Paul Smyth
 
Application of Insert and select notes.ppt x
Application of Insert and select notes.ppt x
doxafo4842
 
Documento de altas
Documento de altas
alejandroDFK
 
Codes
Codes
OSit3
 
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 = ""; } }