C# - DataTable From Session Memory Has No Columns

Jan 18, 2011

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.

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"];

View 1 Replies


Similar Messages:

Memory Hog (DataTable)?

Feb 3, 2010

I have a procedure where I am building a table to store rows of data. I did not think this was to memory intensive. However my form does not seem load effortlessly. I call this procedure in the Form Load Event. Is there a more optimal place (Form Loading Event Procedure) to put code that may require a little more memory than usual?

View 7 Replies

Storing Datatable In Memory?

Feb 23, 2011

I have a datatable with morethan 100o records and around 6 to 7 columns. When I get the data into datatable, I use each field to get distinct values and display in different drodownlists. When all the dropdown lists are filled with data, user selects one of them to filter other dropdown lists with the selected value. I want to know how can I keep datatable data stored till I get all the filtering done. I dont want to store the datatable in session as it may occupy so much of memory. Is there any other way to store the datatable till the end of the process.

View 8 Replies

DataSource Controls :: Datatable/Dataset Total Memory?

Mar 16, 2011

make a query which will give me 200,000 results and bind it to the datatable but the error will pop out saying out of memory or request timed out.Can datatable/dataset handle these records or is my current server's hardware needs a little upgrade?Actually we are gettings millions of data and i dont have any idea how to solve this one? Have you worked on this kind of data? Do you have any idea on how to send my command from server A to server B while server A also processing request and will not wait for server B's result and server B will just update the records in my database, i think this can solve my problem if doing it in parallel.

View 1 Replies

DataSource Controls :: Datatable To Excel Memory Exception?

Feb 1, 2010

[Code]....

View 4 Replies

C# - How To Copy Only The Columns In A DataTable To Another DataTable

Jun 1, 2010

how to copy only the columns in a DataTable to another DataTable?

View 2 Replies

C# - Datatable Subset Of Columns From Another Datatable

Jul 2, 2010

I have a datatable with 17 columns and a bunch of data. I wnat a datatable with only 6 of the columns and the data for those 6 columns. So I need a subset of the original datatable. How do I loop through the original datatable with 17 columns and end up with a datatable with only the 6 columns I want with the corresponding data for those 6 columns?

View 4 Replies

DataSource Controls :: Possible Memory Leak In DataTable.Select Method?

Jun 18, 2010

I have an application which was recently ported from Classic ASP to .NET 3.5. I'm pulling some data from a stored procedure and once retrieved, I'm doing using the Select method on the DataTable in a loop so I don't have to keep going back to the database.It appears that there's something wrong here as I can refresh the page repeatedly and see the memory usage increase by a few megabytes, up to the point where we get an error. If we recycle the app pool in IIS, it starts working again, for a little while.

Is there a memory leak in this method? I did some research on the subject and Microsoft said there was an issue like that in .NET 1.0 and 1.1, but I'm using a higher version.Or, is this something else, such as not managing resources correctly? Here's a snipped of my code:

[Code]....

Initially, this app was using XML instead of a datatable and using XPATH to query the data, but it was too slow. I thought using a dataset with DataTable selects was a better option, but now we found this issue. I was thinking since the loop executes several hundred times that getting all the data and filtering through it on the client was a better choice instead of calling several web methods to get the subsets of data.

View 5 Replies

DataSource Controls :: Recommended Searching Method For In Memory Dataset (datatable)?

Feb 19, 2010

it is apparent that "string builder" is better for building large string compared to sMyString = sMyString + "something";

what is a better way to search large in memory datasets? (like the example above - i know i could use loops, is there another way that i dont now about?)

View 5 Replies

DataSource Controls :: Does Dataset Store All Its Datatables' Records Into Memory If I Just Call One Datatable From It

Apr 2, 2010

Does dataset store all its datatables' records into server memory if I just call one datatable from it?Lets make an example, a dataset with three datatables - tbCompany, tbCompanyStaffs, tbSalesOrderwhere tbCompany is the parent of tbCompanyStaffs. tbSalesOrder is an independant table.Does dataset load all tbCompanyStaffs records into the server memory as well when a class retrive data from tbCompany?

View 3 Replies

Memory - File Or Session For Charting Tools

Aug 16, 2010

Which storage method should I use when using ASP.NET Charting Tools? I'm currently using memory, because it seems like the most straight-forward and easy to implement option. Is there any reasons I should be aware of why I should choose one of the other options? The charts generated will be useful only for an overview kind of purpose (checking to see if a data collection is following a certain pattern, as it is being built day by day), and this function won't be used frequently.

View 1 Replies

Setting Default .Net Session Memory Consumption?

Oct 20, 2010

Some while ago I found a web page explaining the default size of a session was 2048 kb, the minimum was 1 kb.How can this be adjusted? And if some one has links regarding the subject I would be a happy camper :)

View 2 Replies

C# - Storing Classes In Session Variables - How It Works (memory)

Mar 31, 2011

I've read that you can store classes directly into a session variable i.e.

Session["var"] = myclass;

My question is how the memory management works. Does it automatically serialize this into the session on the client side?

Or does it hold the data for the instance of the class in server memory, and just holds a reference in the session object?

View 4 Replies

State Management :: Memory Size Of Session / ArrayList?

Apr 24, 2010

I am using ASP.NET 2.0.

In my applicaion, I store some values in an ArrayList and store this Arraylist in a session variable. I want to know the size of this session variable in memory. Is there any method to do this.

View 6 Replies

ADO.NET :: Columns Are Not A Member Of DataTable

Feb 17, 2011

I am getting this error whilie bulding project. i simply has defined a datatable accessing its rows and columns. don't knw why it says Columns is not a member of 'DataTable.

Error 66 'Columns' is not a member of 'DataTable'. E:DOI1TableReports.aspx.vb 342
Error 65 'Rows' is not a member of 'DataTable'. E:DOI1TableReports.aspx.vb 297
Error 73 'NewRow' is not a member of 'DataTable'. E:DOI1TableReports.aspx.vb 410

View 9 Replies

How Does Session Handling Work / Sessions Eat Up All Memory If Cookies Are Disabled

Oct 28, 2010

In my project I have configured .NET's sessions to go into database.

I also have a global.asax which implements Session_Start().

In Session_Start() I write three things to the session:

The time the session started.

The user's host address.

A serializable device object wrapping the user's agent.

The problem is now that users which don't allow cookies won't allow session cookies either.

(Easily reproducable by putting the site URL to the restricted sites of IE).

If I keep on refreshing (put finger on F5) a new session is created for every request (-> no session cookie). Shortly, the web server process grows to some hundred megabytes.

It does not matter if you use IIS7 or Cassini Local Webserver.

The issue is now: the memory does not get released until the sessions time out. What is the logic here if sessions should really go to database? How long will .NET keep them in memory? Eventually, you'll even get Out Of Memory exceptions!

Anybody know? How to detect and prevent such (almost malicious) "attacks"?

View 2 Replies

Datagrid With 2 Columns That Have Different Datatable Rows?

Feb 9, 2010

i want to make a datagrid with 2 columns and many rows the columns i want to have databinding with a datatable

i want the 1 row 1 column of datagrid have data from 1 row of datatable
i want the 1 row 2 column of datagrid have data from 2 row of datatable
i want the 2 row 1 column of datagrid have data from 3 row of datatable
i want the 2 row 2 column of datagrid have data from 4 row of datatable
......
......

i use something like this

[code]...

but i have two times the same in tha datagrid left and right

View 28 Replies

Controls :: How To Add And Remove Columns In Datatable

Feb 25, 2016

I want to add and remove columns on specific conditions. how it's possible.

Alert: Add and remove  not Hide and show...

View 1 Replies

C# - How To Create An Ilist From DataTable With Unknown Columns

Oct 27, 2010

I have a DataTable that was built from dynamically created SQL, so I do not know the number of columns in the datatable.

How can I convert this datatable into an IList?

EDIT: I am then going to use this to send to a Telerik Grid on the page.

View 3 Replies

SQL Server :: Transpose Rows To Columns In Datatable

Feb 23, 2011

This is datat table format :

TagName Timestamp Value
Tag1 21-2-2011 12
Tag1 22-2-2011 1
Tag2 21-2-2011 13

I want in this Format

TimeStamp Tag1 Tag2
21-2-2011 12 13
22-2-2011 1 0

View 6 Replies

C# - Setup Format For Columns Of DataTable Or GridView?

Apr 2, 2010

How can I setup some format for cells in some column in my DataTable or GridView ?I need to make some double columns rounded , for example :

3.564643 -> 3.56
3.546723 -> 3.55
6.654644 -> 6.65

DataFormatString ?where ?Question still active, I didn't solved the problem :-/

View 2 Replies

Bind RadcomboBox With Multiple Columns From Datatable?

Feb 8, 2011

I would like to bind 'Id', 'Name' and 'Email' from DataTable to RadComboBox. It's possible with ItemTemplate. But I don't want to display 'Email' column in the RadComboBox. I want display 'Email' in the label when the selectedIndexChanged. Is this possible?

View 1 Replies

Forms Data Controls :: Store Gridview Datatable In Session And Then Retrieve From Session And Store Database

Nov 11, 2010

Its related to datatable in gridview store in session and then session retrive and store to database. basically i am using gridview here creating new row for button click and these row adding untill user's last entry then submit all these entry to database. so i want to use session variable to store this data temporarily and after final entry user click on submit button and all data shold be save in db.

View 9 Replies

Forms Data Controls :: Filter The Columns Of A DataTable?

Aug 2, 2010

I've built a User Control that contains a ListView. To make it work I need to pass to it a DataTable. The columns of this DataTable need to have particular names that match up with what the ListView is expecting. I have a large DataTable that I need to massage/convert over to this different format. To do that I need to filter out columns and rename the column names. The actual data in the DataTable doesn't need to change. Is there a good way to do this without actually instantiating a new DataTable and copying the data from the large DataTable into it?

View 14 Replies

Forms Data Controls :: Specify Which Columns Are In A DataView From A DataTable?

Mar 24, 2010

HOW TO specify which columns are in a DataView from a DataTable. I want to create a DataView, that only has the columns from a DataTable that I choose, and in the order I want.

Example:
// DataTable_MyTable ~~ Column #0 is for ID. I do not want my view to get this column.
// DataTable_MyTable ~~ Column #1 is for TYPE. I want this column to come in 2nd place in my view.
// DataTable_MyTable ~~ Column #2 is for NAME. I want this column to com in 1st place in my view.

DataView DataView_MyView = new DataView(DataTable_MyTable ~~ some how only get the columns I want, and in the order I want ~~);

// DataView_MyView now has only 2 columns.
// DataView_MyView ~~ Column #0 is NAME.
// DataView_MyView ~~ Column #1 is TYPE.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved