473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

DataTable in a Session variable

How do I define, store and retrieve a dataTable from a Session variable?

Sep 11 '06 #1
4 10396
jpabick,

Add it first to a dataset, than it is very simple (typed here watch errors)
DataSet ds = new DataSet();
ds.Tables.Add(myTable)
Session.Item("ds") = ds;

I hope this helps,

Cor
"jpabich" <jp*****@eisincorporated.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
How do I define, store and retrieve a dataTable from a Session variable?

Sep 11 '06 #2
I don't think this helps. I need the session variable to be able to be
accessed from another screen. I have it defined as;

/// <summary>
/// Session variable to hold the execption table
/// </summary>
public static DataTable SESSION_EXCEPTION_TABLE = null;

Add Table to it as;

HttpContext.Current.Session[SESSION_EXCEPTION_TABLE] =
ViewState["dtbException"];
Retrieve it as:
dtbWrite =
Convert.ToString(HttpContext.Current.Session[RecordCount.SESSION_EXCEPTION_TABLE]);

I get complie errors on all of this.

Cor Ligthert [MVP] wrote:
jpabick,

Add it first to a dataset, than it is very simple (typed here watch errors)
DataSet ds = new DataSet();
ds.Tables.Add(myTable)
Session.Item("ds") = ds;

I hope this helps,

Cor
"jpabich" <jp*****@eisincorporated.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
How do I define, store and retrieve a dataTable from a Session variable?
Sep 11 '06 #3
C# is strongly typed, so you have to cast anything you get out of session to
its appropriate data type.

Also, if what you are putting into session is a DataTable, why are you
converting it to a string when you take it out?

"jpabich" <jp*****@eisincorporated.comwrote in message
news:11*********************@d34g2000cwd.googlegro ups.com...
>I don't think this helps. I need the session variable to be able to be
accessed from another screen. I have it defined as;

/// <summary>
/// Session variable to hold the execption table
/// </summary>
public static DataTable SESSION_EXCEPTION_TABLE = null;

Add Table to it as;

HttpContext.Current.Session[SESSION_EXCEPTION_TABLE] =
ViewState["dtbException"];
Retrieve it as:
dtbWrite =
Convert.ToString(HttpContext.Current.Session[RecordCount.SESSION_EXCEPTION_TABLE]);

I get complie errors on all of this.

Cor Ligthert [MVP] wrote:
>jpabick,

Add it first to a dataset, than it is very simple (typed here watch
errors)
DataSet ds = new DataSet();
ds.Tables.Add(myTable)
Session.Item("ds") = ds;

I hope this helps,

Cor
"jpabich" <jp*****@eisincorporated.comschreef in bericht
news:11**********************@i42g2000cwa.googleg roups.com...
How do I define, store and retrieve a dataTable from a Session
variable?

Sep 11 '06 #4
Hi ,

if you declare your dataset static it will not be scoped in your session but
in your Application, all the sessions will share teh same dataset !!!
Add Table to it as;

HttpContext.Current.Session[SESSION_EXCEPTION_TABLE] =
ViewState["dtbException"];
You have errors there, Session expect either a string or a integer to
retrive from the session collection, a DataTable will not compile, change it
to:
Session["Exception_Table"] = ....;

>
Retrieve it as:
dtbWrite =
Convert.ToString(HttpContext.Current.Session[RecordCount.SESSION_EXCEPTION_TABLE]);
Idem.

Again, you are declaring the datatable as static, this is an error !
OR you dont want it in session
What is what you are trying to do in the first place?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Sep 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Kandell | last post by:
Hi, I posted this in the asp.net group, but didn't get a response. Maybe someone here can help me with this... --- Would someone be able to shed some light on what is the cost of saving a...
0
by: Drew | last post by:
Hello- I have am ASP.Net DataGrid object that I bind to from the result of a query. In order to not retrieve this dataset again when the user presses forward and back, I keep the dataset in a...
1
by: Paul Perot | last post by:
Hi All: I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the server. I use this datatable...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
2
by: ven | last post by:
Hello i have a dynamic datatable in my page. I wanna to write data to textboxes and after click on button "ADD data" i want to refresh datagrid on page... Here is my code : ' Insert page code...
1
by: srinivas | last post by:
HI, I have 4 text boxes and one button in my page. When ever I fill the text boxes and click the button the data should be add to a datagrid with out inserting a record in database. For this I...
2
by: mark4asp | last post by:
Can I cache a DataTable (or alternative GridView Datasource) in a Session object? .... and does the following scenario present itself as an occaison when I could get away with doing so? In an...
4
by: =?Utf-8?B?YmFzdWxhc3o=?= | last post by:
Hi; I want to store a datatable (or an arraylist) as a session variable but when I try; Session = al_RecNo; I get an error that; "Cannot implicitly convert type...
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.