473,411 Members | 2,083 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,411 software developers and data experts.

Asp.Net session vs. Database Queries.

DNB
I did post this message in C# group also...

I would like to know what you guys think is the best way to access data:
Asp.Net session vs. Database Queries.

In our application we are using asp.net tree view to display hierarchical
data and when user clicks on particular node it brings up totally different
page with all the asp.net controls dynamically generated.
Example:
Tree view Control is as follow:
Student1
Student2
Student3
Student4
.......
......
.....
.....
Student 75

Now I have 2 options:
1) Now when user click on any node (i.e. Node Student2) another page will be
displayed and all the data related to that will be accesses from SQL server
using SQL Queries

2) OR Should all the data be accessed initially loaded into Session
Variable before building Tree View and when user access Node Student 2, just
get it from Session Variable.

Thanks
DNB
Nov 29 '07 #1
3 1575
If the dataset is small and unchanging you could store it in the
Application, or in some static (shared in VB.net) class properties. If the
dataset is large and/or frequently updated you're better getting it from the
database.
"DNB" <ii@ii.comwrote in message
news:Of**************@TK2MSFTNGP06.phx.gbl...
>I did post this message in C# group also...

I would like to know what you guys think is the best way to access data:
Asp.Net session vs. Database Queries.

In our application we are using asp.net tree view to display hierarchical
data and when user clicks on particular node it brings up totally
different
page with all the asp.net controls dynamically generated.
Example:
Tree view Control is as follow:
Student1
Student2
Student3
Student4
......
.....
....
....
Student 75

Now I have 2 options:
1) Now when user click on any node (i.e. Node Student2) another page will
be
displayed and all the data related to that will be accesses from SQL
server
using SQL Queries

2) OR Should all the data be accessed initially loaded into Session
Variable before building Tree View and when user access Node Student 2,
just
get it from Session Variable.

Thanks
DNB


Nov 29 '07 #2
Make your life easier, go ahead and load from the DB every time.

Unless you expect users to frequently click every node in the tree in rapid
succession, in which case you might want to reconsider your UI design
anyway.
"DNB" <ii@ii.comwrote in message
news:Of**************@TK2MSFTNGP06.phx.gbl...
>I did post this message in C# group also...

I would like to know what you guys think is the best way to access data:
Asp.Net session vs. Database Queries.

In our application we are using asp.net tree view to display hierarchical
data and when user clicks on particular node it brings up totally
different
page with all the asp.net controls dynamically generated.
Example:
Tree view Control is as follow:
Student1
Student2
Student3
Student4
......
.....
....
....
Student 75

Now I have 2 options:
1) Now when user click on any node (i.e. Node Student2) another page will
be
displayed and all the data related to that will be accesses from SQL
server
using SQL Queries

2) OR Should all the data be accessed initially loaded into Session
Variable before building Tree View and when user access Node Student 2,
just
get it from Session Variable.

Thanks
DNB

Nov 29 '07 #3
In general, I like to persist data in a database until it is going to be
used. You can prefetch some data, but loading a lot of data into session (or
cache) is not generally the first choice, as most of it will never be used.

In this case, I would NEVER use Session. Caching might be an option,
depending on the nature of the application.

Example: Seventy five students. Prefetch all data about the students and
cache (In this case, better than session). User clicks a single student. You
now have seventy four student's data loaded in session (ie, in memory) for
the length of the session, even though only one was used.

Here is why caching is preferred over session. You cache once across all
sessions, so the same data is available to all people using the particular
page. The cache can be set to update occasionally or, in custom situations,
based on events (very easy if using SQL 2005, 2008 -- requires polling in
2000). If 100 people are using this app at the same time, you have saved 99%
of the memory used to cache over loading in each session.

Here is why caching is not necessarily wise in this case: The more students,
the more information you are caching. And, this is likely to be information
you can just as easily query as needed (caching the query may or may not be
wise, depending on how many times the same person will access the same
record). You can also set cache to expire independently of session timeout.
If the information can be pulled as needed, with perhaps a temporary cache,
I would head this direction.

Now to your options
1) Now when user click on any node (i.e. Node Student2) another page will
be
displayed and all the data related to that will be accesses from SQL
server
using SQL Queries
This can be another page or another control on the same page. GridView and
DetailsView work very nicely together to make the application flow. Throw in
an AJAX UpdatePanel and you can even have the information flow in without a
full server round trip.
2) OR Should all the data be accessed initially loaded into Session
Variable before building Tree View and when user access Node Student 2,
just
get it from Session Variable.
Very rarely do I try to prefetch, much less into session

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
Nov 29 '07 #4

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

Similar topics

4
by: dr. zoidberg | last post by:
Hello, I'm trying to create login system. I need some advices. Should I put Username and Password in session, and then check database for correct combination on every page, or should I just put...
5
by: Timin Uram | last post by:
Hey! Is there some sort of limit on how much one could store in a session as far as amount of data? Is it advisable to store a LOT of data in the session when a user logs in to save queries to...
14
by: mjkahn | last post by:
I've read (and read!) that you shouldn't store objects in Session variables. I've read these reasons: - The object takes up memory that may not be freed until the session times out. Better to...
2
by: eselk | last post by:
I'm new to ASP. If I store information in these handy "session variables" am I going to run into many limitations that I wouldn't have it I added a database record for each session instead? For...
9
by: Mikel Astiz | last post by:
Hi, I am looking for a simple way to detect session ends so I can update a session table. I am new to PHP and don't understand how such event can be handled, since there seems not to be a...
3
by: Martin | last post by:
Hi all As my posting title suggests I'm having problems using InProc Session state in my ASP .NET app. I wrote a site for a friend which uses ADO .NET to keep track of a simple...
4
by: John Allberg | last post by:
Hi! We have a problem which is correlated to web farms and session handling and are thinking of what solution to choose. Our setup is with a web farm, one ldap server and a database cluster. ...
14
by: Rick | last post by:
We are in the process of testing a large web project that I converted from VS 2003 to VS 2005. Everything seems to be working except for a few minor things. But the main issue I have is this, I...
6
by: DNB | last post by:
I would like to know what you guys think is the best way to access data: Asp.Net session vs. Database Queries. In our application we are using asp.net tree view to display hierarchical data and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.