ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication

Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses


  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > Working with DataSets

ASP.NET Tutorial - Working with DataSets

                                                                                                                 Page 5 of 5

Displaying Cached Data

Considering that there is an Employee’s adress book, that is continuously being used by the employee’s, is not being updated daily with their record. If all the employee want to see the address book page(employee record) the server has to respond to every user. Therefore to save the resources of the webserver for other processing, and to make the program memory resident we the page can be cached in the computer’s cache memory instead of the database.

The following example demonstrates it:


Example 55 CacheAddressbook.aspx

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.SqlClient" %>

<Script Runat="Server">

Sub Page_Load

If Not IsPostBack Then

' Bind to datagrid

dgrdEmployees.DataSource = GetEmployees()


End If

End Sub

Function GetEmployees() As DataView

Dim dstEmployees As DataSet

Dim conNorthwind As SqlConnection

Dim dadEmployees As SqlDataAdapter

Dim dvwEmployees As DataView

dvwEmployees = Cache( "Employees" )

If dvwEmployees Is Nothing Then

dstEmployees = New DataSet()

conNorthwind=New SqlConnection( "Server=localhost; UID=sa;PWD=secret;Database=Northwind" )

dadEmployees = New SqlDataAdapter( "Select * from Employees", conNorthwind )

dadEmployees.Fill( dstEmployees, "Employees" )

dvwEmployees=dstEmployees.Tables("Employees"). DefaultView()

Cache( "Employees" ) = dvwEmployees

End If

Return dvwEmployees

End Function

Sub dgrdEmployees_SortCommand( s As Object, e As DataGridSortCommandEventArgs )

Dim dvwEmployees As DataView

 ' Sort DataView

dvwEmployees = GetEmployees()

dvwEmployees.Sort = e.SortExpression

 ' Rebind to DataGrid

dgrdEmployees.DataSource = dvwEmployees


End Sub





 <form Runat="Server">





Runat="Server" />





In the above example the DataGrid that displays the list of employee, uses the DataView, returned by the GetEmployees () function as its data source. This function attempts to retrieve a DataView containing the employee’s information from Cache object.

The AllowSorting property of DataGrid is set positive (True) so that the data can be sorted, according to Order by clause of SQL Statements to any column. Moreover even if the database server is stopped then also the page will run, because of its inclusion into the cache memory of the computer. Likewise server resources can be saved for handling other processes.

Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
© ExpertRating 2015. All Rights Reserved.