Wednesday, September 23, 2009

using System.Web.Caching;
using System.Data.SqlClient;

public partial class MyCaching : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds;
ds = (DataSet)Cache["firmCustomers"];
if (ds == null)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GetitDMConnectionString2"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("Select top 20 areaname, pincode from area", conn);
ds = new DataSet();
da.Fill(ds);
SqlCacheDependency myDependency = new SqlCacheDependency("DMS", "area");
Cache.Insert("firmCustomers", ds, myDependency);
Label1.Text = "Produced From database";
}
else
{
Label1.Text = "Produced From Cache";
}
GridView1.DataSource = ds;
GridView1.DataBind();
}
}

=======================
Enabling the Database and Table

d:\program files\microsoft visual studio 9.0\VC>
Run these commands in Command promt On above prompt
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 -d DMS -ed
aspnet_regsql.exe -S "192.168.0.181" -U sa -P sa123 - d DMS -t Userlogin -et

========================
//webconfig
Symbols:
LL Means Less Than
GG Means Greater Than












No comments: