QUERYING THE DATASET

S

sharmaajay

hi all,
i want to know whether we can make a dataextract function in global
page(global.asax) though a query and.. then for each individual .aspx
page can we query tht dataset instead of creating dataset for each page
individual page???


i'll appriciate ur help


regards
AJAY
 
S

sloan

I would suggest something like below.

It will put an object in the Application scope.... if it doesn't exist, it
hits the db.
If it exists , it returns the cached copy.
If you pass a "true" to it, it refreshes the data.



public DataSet GetGoodEnoughData( bool forceRefresh )
{


string key = "myuniquekey";
bool needToHitDatabase = false;
DataSet ds;

if(!forceRefresh)
{
if( null ==Application[key]) )
{
needToHitDatabase = true;
}
}
else
{
needToHitDatabase = true;
}
if(needToHitDatabase ==true)
{
ds = SomeBusinessObject.GetDataSet();
Application[key] = ds;
}
else
{
ds = Application[key] as DataSet;
}

return ds;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top