Professional Documents
Culture Documents
Practical No: 6B Aim: Create A Web Application To Display Records by Using Database
Practical No: 6B Aim: Create A Web Application To Display Records by Using Database
Practical No: 6B Aim: Create A Web Application To Display Records by Using Database
1] WebForm1.aspx
<div>
<asp:TextBox ID="TextBox1" runat="server"
AutoPostBack="True"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:EMPLOYEEConnectionString2
%>" SelectCommand="SELECT [Id], [name], [salary] FROM
[emp]"></asp:SqlDataSource>
</div>
2] WebForm1.aspx.cs
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 prac6B
{
public partial class WebForm2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=DESKTOP-
123\\SQLEXPRESS;Initial Catalog=EMPLOYEE;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
cmd.Connection = con;
}
Output: