How to implement caching?

Answer Posted / sivasaravanan

Data caching:

DataView Source;
//Declare variable for caching
Source = (DataView)Cache["MyDataset"];
if (Source == null)
{
OleDbConnection objcon = new OleDbConnection
(ConfigurationManager.ConnectionStrings
["strcon"].ConnectionString);
OleDbDataAdapter objcmd = new OleDbDataAdapter
("select * from Customer", objcon);
DataSet objds = new DataSet();
objcmd.Fill(objds, "Customer");
Source = new DataView(objds.Tables["Customer"]);
Cache["MyDataset"] = Source;
Label1.Text = "Dataset created explicitly";


}
else
{
Label1.Text = "Dataset retrived from Cache";
}
GridView1.DataSource = Source;
GridView1.DataBind();
gridbind();

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do we implement bundling in MVC?

585


What’s the difference between response .redirect and server.transfer?

510


What threading model used in asp and asp.net?

568


Explain the boxing and unboxing concept in .net?

381


What is the difference between the response.write() and response.output.write() methods?

507






If you have an application with multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers by using round-robbin load balancing. Explain which is the best approach to maintain login-in state for the users?

598


What are session state modes in asp.net?

547


To add a hyperlink column to the DataGrid which tag is used ?

579


What kind of data we can store in viewstate?

574


What are the ways to show data grid inside a data grid for a master details type of tables? If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?

582


Whats the difference between abstract factory pattern and factory pattern?

595


Can a master page have more than one contentplaceholder?

506


How would you implement inheritance using c#?

573


What is asp.net ajax?

550


Why do we use datasource in asp.net?

521