Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / April 2004

Tip: Looking for answers? Try searching our database.

Help with Using a DataSet in Session State

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jaka - 31 Mar 2004 00:33 GMT
Hello...  I need some help/advice regarding using a dataset in session state.

When a request first comes to my ASP.NET application, I have code in the Session_Start event to query the user table, which return a dataset.  I then add this dataset to a Session variable.

This works, but my questions are:

1.  Is storing a dataset in session state the best approach to handle my situation?  Or, is there some better alternative?  Note that the queried results are user-specific, so application cache wouldn't work.

2.  Assuming I go forward with the dataset in session state idea, how do I access an individual element in the data table in the data set that's in the session state variable?

I have this code:

System.Data.DataSet ds = (System.Data.DataSet) Session["reportLogonUser"];

But, then what?

Thanks.
Alvin Bruney [MVP] - 04 Apr 2004 01:21 GMT
For 1, it is a common approach.

For2, now that you have the dataset, you can iterate it for your results. You can think of the datatable as a grid matrix which allows direct access like so
string str = ds.Tables[0].Rows[2][3].ToString();

or if you don't know exactly where it is, you can iterate the datatable or use the find function of the datatable which is optimized for lookups and guaranteed to be faster than iteration since it is based on indices/indexes.

Signature

Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok

 Hello...  I need some help/advice regarding using a dataset in session state.

 When a request first comes to my ASP.NET application, I have code in the Session_Start event to query the user table, which return a dataset.  I then add this dataset to a Session variable.

 This works, but my questions are:

 1.  Is storing a dataset in session state the best approach to handle my situation?  Or, is there some better alternative?  Note that the queried results are user-specific, so application cache wouldn't work.

 2.  Assuming I go forward with the dataset in session state idea, how do I access an individual element in the data table in the data set that's in the session state variable?

 I have this code:

 System.Data.DataSet ds = (System.Data.DataSet) Session["reportLogonUser"];

 But, then what?

 Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.