Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3698378
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:58:27+00:00 2026-05-19T04:58:27+00:00

Im trying to retrieve a datatable that I put into a session variable, however

  • 0

Im trying to retrieve a datatable that I put into a session variable, however when i do it apears that there are no columns…

I have done this before in VB.NET, I’n now using C#, and it worked perfectly, and as far as i can see there is no change in the code other than the obvious syntax changes.

EDIT:

The dt (in part 2) variable has the right data when i look in the data visulization window, but i have noticed that the other properties associated with a datatable are abscent. When i hover over a normal looking datatable with my mouse it looks like the following: ” dt —– {System.Data.DataTable}” but in the class im working on it just looks like “dt —– {}”. Also, after I return the session variable into the dt I clone it (dtclone = dt.clone(); ) and the clone is empty in the data visulizer…. what on earth!

EDIT 2:

I have now also tried converting the first datatable to a dataset, putting this in the session variable, and recoverting it back to a datatable in the class.

Am starting to wonder if it is a probelm with:

    dt.Load(sqlReader);

The data does appear after this step though in the dataset visualiser, but not after being cloned.

Code below.

All help very welcome!

Thanks in advance

Chris

1) SQL command in a webhandler, the results of which populate the datatable to be put into the session variable.

    DataTable dt = new DataTable();

    SqlDataReader sqlReader= default(SqlDataReader);        
    SqlDataAdapter sqlAdapter = new SqlDataAdapter();

    sqlReader = storedProc.ExecuteReader(CommandBehavior.CloseConnection);

    dt.Load(sqlReader);
    System.Web.HttpContext.Current.Session["ResultsTable"] = dt;

2) Part of the code in a class which performs calculations on the table:

    DataTable dt = (DataTable)HttpContext.Current.Session["ResultsTable"]; 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:58:27+00:00Added an answer on May 19, 2026 at 4:58 am

    did you call DataTable dispose after setting Session Var?
    Because if you do this, solution is like this:

    System.Web.HttpContext.Current.Session["ResultsTable"] = dt.Copy();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve column descriptions for MS Access columns using C# (the
I'm trying to retrieve data using the new graph API, however the token I'm
i trying to retrieve value by referencing primary key in multiple tables but unable
I'm trying to retrieve the text value from a JTextField but first I need
I am trying to retrieve some data from a database using jQuery's $.getJSON method
I am trying to retrieve user email via facebook after user authentication on my
I am trying to retrieve a count of orders for each order type (OrderTypeID)
Ok, so I'm aware of this issue: When SET ANSI_NULLS is ON, all comparisons
I am aware of the various posts floating out there with regards to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.