0% found this document useful (0 votes)
36 views6 pages

Practical No 8

Uploaded by

vishal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views6 pages

Practical No 8

Uploaded by

vishal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Practical no.

08
Pr 8a: Create a web application to demonstrate various uses and properties of SqlDataSource.
code:
using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Data.SqlClient;

namespace pr8a

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

SqlCommand co = new SqlCommand();

SqlDataReader ds;

SqlDataSource s = new SqlDataSource();

protected void Page_Load(object sender, EventArgs e)

s.ConnectionString = "Data Source=DESKTOP-63TIL74\\SQLEXPRESS;Initial


Catalog=pr8a;Integrated Security=True";

protected void Button1_Click1(object sender, EventArgs e)

s.SelectCommand = "select * from students;";

GridView1.DataBind();

}
protected void Button2_Click1(object sender, EventArgs e)

SqlParameter p1 = new SqlParameter(), p2 = new SqlParameter(), p3 = new SqlParameter(), p4 =


new SqlParameter();

s.InsertParameters.Add("p1", System.Data.DbType.String, TextBox1.Text);

s.InsertParameters.Add("p2", System.Data.DbType.String, TextBox2.Text);

s.InsertParameters.Add("p3", System.Data.DbType.String, TextBox3.Text);

s.InsertParameters.Add("p4", System.Data.DbType.String, TextBox4.Text);

s.InsertCommand = "Insert into student values(@p1,@p2,@p3,@p4);";

s.Insert();

protected void Button3_Click1(object sender, EventArgs e)

SqlParameter p1 = new SqlParameter(), p2 = new SqlParameter();

s.UpdateParameters.Add("p2", System.Data.DbType.String, TextBox2.Text);

s.UpdateParameters.Add("p1", System.Data.DbType.String, TextBox1.Text);

s.UpdateCommand = "update student SET name=@p2 where sno=@p1;";

s.Update();

protected void Button4_Click1(object sender, EventArgs e)

SqlParameter p1 = new SqlParameter();

s.DeleteParameters.Add("p1", System.Data.DbType.String, TextBox1.Text);

s.DeleteCommand = "delete student where sno=@p1;";

s.Delete();

}
Design:

Output: Insert
Output: Modify

Output: delete
8b: Create a web application to demonstrate data binding using DetailsView and FormView Control.
output:
8c: Create a web application to display Using Disconnected Data Access and Databinding using
GridView.
Design:

Output:

You might also like