Code Implementation
ViewEmployee.aspx
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="ViewEmployee.aspx.vb" Inherits="ViewEmployee" %>
<!DOCTYPE html>
<html>
<head>
<title>View Employee Data</title>
</head>
<body>
<form runat="server">
<h2>Employee List</h2>
<asp:GridView ID="gvEmployees" runat="server" AutoGenerateColumns="true" />
</form>
</body>
</html>
ViewEmployee.aspx.vb
Imports System.Data
Imports System.Data.SqlClient
Partial Class ViewEmployee
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim connStr = "Server=localhost\SQLEXPRESS02;Database=PayrollDB;Trusted_Connection=True;"
Using conn As New SqlConnection(connStr)
Dim query = "SELECT EMPLOYEE_ID, NAME, EMAIL, PHONE FROM Employee_New"
Dim cmd As New SqlCommand(query, conn)
Dim adapter As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
adapter.Fill(dt)
gvEmployees.DataSource = dt
gvEmployees.DataBind()
End Using
End If
End Sub
End Class