<%@ Page Language="VB" Trace="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
sub Page_Load(Sender as Object, e as EventArgs)
Trace.Warn("Custom", "Page loading...")
if not Page.IsPostBack then
Trace.Warn("Custom", "No post")
CreateData()
end if
end sub
sub CreateData
dim source as DataView
source = Cache("DataView")
if source is nothing then
dim strConnString as string = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("EmployeeDatabase.mdb;")
Trace.Warn("Custom", "Creating OleDbDataAdapter...")
dim objCmd as OleDbDataAdapter = new _
OleDbDataAdapter("select * from employee", _
strConnString)
Trace.Warn("Custom", "SQL value: " & _
objCmd.SelectCommand.CommandText)
dim ds as DataSet = new DataSet()
objCmd.Fill(ds, "employee")
source = new DataView(ds.Tables(0))
Trace.Warn("Custom", "Inserting into cache...")
Cache.Insert("DataView", source)
lblMessage.Text = "Data set created explicitly"
else
lblMessage.Text = "Data set retrieved from " & _
"cache<br>"
end if
Trace.Warn("Custom", "Binding data...")
dgData.DataSource = source
dgData.DataBind()
end sub
sub ExpireCache(Sender as Object, e as EventArgs)
Trace.Warn("Custom", _
"Removing from cache, call CreateData")
dim dv as dataview = Cache.Remove("DataView")
CreateData()
end sub
</script>
<html><body>
<form runat="server">
<asp:Label id="lblMessage" runat="server"
maintainState=false/>
<asp:Button id="btSubmit" runat="server"
text="Expire Cache"
OnClick="ExpireCache"/>
<asp:DataGrid id="dgData" runat="server"
BorderColor="black" GridLines="Vertical"
cellpadding="4" cellspacing="0"
width="450" Font-Name="Arial"
Font-Size="8pt"
/>
</form>
</body></html>
File: web.config
<configuration>
<system.web>
<trace enabled="true"/>
</system.web>
</configuration>