using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data;

using System.Data.SqlClient;

public partial class Default4 : System.Web.UI.Page

{

 

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

SqlConnection con;

con = new SqlConnection(@”Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\bsc\sem  5\dot net\WebSite67\WebSite67\App_Data\Database2.mdf;Integrated Security=True”);

con.Open();

string up = “insert into Table1 values(@id,@name)”;

string show = “select * from Table1”;

SqlCommand cmd = new SqlCommand(up, con);

SqlCommand csd = new SqlCommand(show, con);

cmd.Parameters.AddWithValue(“@id”, TextBox1.Text);

cmd.Parameters.AddWithValue(“@name”, TextBox2.Text);

cmd.ExecuteNonQuery();

SqlDataReader dr = null;

dr = csd.ExecuteReader();

GridView1.DataSource = dr;

GridView1.DataBind();

dr.Close();

}

protected void Button2_Click(object sender, EventArgs e)

{

SqlConnection con;

con = new SqlConnection(@”Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\bsc\sem  5\dot net\WebSite67\WebSite67\App_Data\Database2.mdf;Integrated Security=True”);

con.Open();

string up = “update Table1 set name=@name where id=@id”;

SqlCommand cmd = new SqlCommand(up, con);

cmd.Parameters.AddWithValue(“@id”, TextBox1.Text);

cmd.Parameters.AddWithValue(“@name”, TextBox2.Text);

cmd.ExecuteNonQuery();

string show = “select * from Table1″;

SqlCommand csd = new SqlCommand(show, con);

SqlDataReader dr = null;

dr = csd.ExecuteReader();

GridView1.DataSource = dr;

GridView1.DataBind();

dr.Close();

}

protected void Button3_Click(object sender, EventArgs e)

{

SqlConnection con;

con = new SqlConnection(@”Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\bsc\sem  5\dot net\WebSite67\WebSite67\App_Data\Database2.mdf;Integrated Security=True”);

con.Open();

string up = “delete from Table1 where id=@id”;

SqlCommand cmd = new SqlCommand(up, con);

cmd.Parameters.AddWithValue(“@id”, TextBox1.Text);

cmd.ExecuteNonQuery();

SqlDataAdapter da = null;

da = new SqlDataAdapter(“select * from Table1″, con);

DataSet ds = new DataSet();

da.Fill(ds);

GridView1.DataSource = ds;

GridView1.DataBind();

}

}

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default4.aspx.cs” Inherits=”Default4″ %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head runat=”server”>

<title></title>

</head>

<body>

<form id=”form1″ runat=”server”>

<div>

 

ID:

<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>

Name:

<asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox>

<asp:Button ID=”Button1″ runat=”server” onclick=”Button1_Click” Text=”Insert” />

<asp:Button ID=”Button2″ runat=”server” onclick=”Button2_Click” Text=”Update” />

<asp:Button ID=”Button3″ runat=”server” onclick=”Button3_Click” Text=”Delete” />

 

<asp:GridView ID=”GridView1″ runat=”server”>

</asp:GridView>

 

</div>

</form></body></html>

 

 

 

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

©2018 MYBSCIT.com. An initiative by some failures to make student scholars.

or

Log in with your credentials

Forgot your details?