Advertisement

06.04.2008 at 02:07AM PDT, ID: 23455982
[x]
Attachment Details

Caching a datatable C# - ASP.NET

Asked by yellow1234 in .NET Framework 2.x, C# Programming Language

Tags:

I am trying to cache a data table.
In this code snippet I try to find out whether the cached datatable exists, if not I will create a table, load data and add it to the cache.

Cache cache = new Cache();
DataTable dt = new DataTable();
dt = (DataTable)cache.Get("MyTable");
       
if (dt==null)
{
 //create data table, load data and add to cache.
}

The problem is that code gives an error on line     dt = (DataTable)cache.Get("MyTable");
System.NullReferenceException: Object reference not set to an instance of an object

What am I overlooking here? Thanks!Start Free Trial
[+][-]06.04.2008 at 02:14AM PDT, ID: 21708169

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 02:22AM PDT, ID: 21708208

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 07:58AM PDT, ID: 21720271

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 08:06AM PDT, ID: 21720383

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 08:10AM PDT, ID: 21720429

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 08:13AM PDT, ID: 21720455

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 08:19AM PDT, ID: 21720521

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.x, C# Programming Language
Tags: C# ASP.NET
Sign Up Now!
Solution Provided By: renjurdevan
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.05.2008 at 08:34AM PDT, ID: 21720729

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 08:56AM PDT, ID: 21720982

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628