Subhash Sharma

Subhash Sharma
Subhash Sharma

This is Subhash Sharma(Software Engineer) Blog

Welcome to this blog and find every solution.............

Search This Blog

Software Engineer(Subhash Sharma)

Software Engineer(Subhash Sharma)
Software Engineer
Showing posts with label Cache object use for dataBase Access(Application Level Caching/Programmatic and Data Caching). Show all posts
Showing posts with label Cache object use for dataBase Access(Application Level Caching/Programmatic and Data Caching). Show all posts

Friday, March 4, 2011

Cache object use for dataBase Access(Application Level Caching/Programmatic and Data Caching)

//First Page where we store dataset values into caching and use that value another page...

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["kumarConnectionString"].ConnectionString);

SqlCommand cmd = new SqlCommand("select Id,Name from emp", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
Cache.Insert("user", ds);

/////second page access caching value..........

if (Cache["user"] != "")
{
ds = (DataSet)Cache["user"];
GridView1.DataSource = ds;
GridView1.DataBind();

}