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

What is tracing? Where is it used?

567


What is the sequence in which ASP.NET events are processed?

484


Can the validation occurs in server-side or client-side? If the validation occurs why should we do?

611


Which protocol is used to call a web service?

577


What are custom user controls in asp.net?

528






What is the exact purpose of http handlers?

576


What is the compiled object?

1652


Is asp.net 64-bit enabled? How?

601


What is an axd file?

604


Explain how can you debug your .net application?

542


Write a code snippet to implement the indentation in json in web api.

584


Explain the steps to be followed to use passport authentication.

607


Is it possible to create web application with both webforms and mvc?

547


How can you enable impersonation in the web.config file?

572


What are the different authentication modes in asp.net?

530