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 are Caching techniques in .NET

795


What are directives in asp.net?

694


What is data grid view in asp.net?

696


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

773


How can we prevent browser from caching an aspx page?

697


What is difference between singleton and single call?

821


How to register exception filter globally?

787


What is Razor View Engine

819


What is the difference between user control and custom control?

682


What is a session in programming?

742


Do you know about caching with the datasource controls?

672


Differentiate between file-based dependency and key-based dependency.

716


Which is an advantage of application service providers?

669


What is the purpose of session management?

700


What are the advantages of asp.net?

725