We help IT Professionals succeed at work.
Get Started

Question about saving a datatable to session state

georgelesser
georgelesser asked
on
336 Views
Last Modified: 2008-01-09
I am using .NET 2.0 and try (if possible) to dispose of objects before leaving the procedure where they are declared.

I saved a datatable to a session variable and then set the datatable to nothing and disposed of it an I noticed that as soon as I set the datatable to nothing, the rows in the session object became 0.

I always thought that saving a something as a session object made a copy.  However, this behavior indicates that there is still some kind of link or pointer.

I need to preserve the datatable in memory (session) for a while and don't want it to suddenly disappear.

Can someone explain what's going on and let me know the best way to approach this issue?

Should I save a clone of the data table?

session("datatbl")=datatable1.clone()  

Thanks!
Comment
Watch Question
Top Expert 2005
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE