473,698 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp.net Session vs Database Queries

DNB
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 28 '07 #1
6 2436

"DNB" <ii@ii.comwro te in message
news:Oz******** ******@TK2MSFTN GP04.phx.gbl...
>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.
You can use SQL Server as a state server, which you set that up through the
Web.config, you set up SQL server to be a state server with the .Net Utility
that does configuration. Then you can make a serialized Session object to
hold you session object in session with the data or variables serialized and
saved and retrieved to/from SQL Server. .Net will keep track and take care
of what needs to be done by itself to keep all session state. All you do is
set and get the object.

Look it up use Google and find out how to keep session state using SQL
server as a state server.
Nov 29 '07 #2
use datbase queries it will faster baecause . when u use session object u
have to create session for every student. and this will seprate for every
user . so memory use at sever will increase which will degrade ur performace.
so better to use dbdbase query. it may happen a user it wisting ur site and
only clicking one node so ur query will fired only once. but when u use
seesion it will create each variable for every user.
for better performace u can also use cahing .

"DNB" wrote:
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
You should consider (if Possible) getting all the data for a particular
user's session and store it in Session State. Unless the amount of data that
is needed is very large, this is the most efficient way of handling a
multiuser application and avoids having to constantly query the database for
what may be the same data. If you have data that is the same across multiple
users, you can save memory by storing that data in either Cache or
Application state.

Also, consider asking questions like this in the asp.net newsgroup as it is
not really a C# language related question.

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

"DNB" wrote:
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 #4
ANSWERED in ASP.NET group.

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

*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
"DNB" <ii@ii.comwro te in message
news:Oz******** ******@TK2MSFTN GP04.phx.gbl...
>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 #5
The issue here, as I read it, is whether to store junk into Session, not how
to do session state. Regardless of whether you are using SQL Server or State
Server (or local for that matter), throwing items into session is not
generally the wisest method. For Prefetch, session is really not a good
option, as you are loading up tons of objects you will never use. One could
prefetch into ViewState, but if there are lots of students on a page, you
get a very heavy page. Once again, for information you most likely will not
use (maybe one or two records). With ViewState, you might get away with it
on a fast connection, but there is really no need.

Better to fetch from your persistant data store as needed.

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

*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
"Mr. Arnold" <MR. Ar****@Arnold.c omwrote in message
news:ek******** ******@TK2MSFTN GP02.phx.gbl...
>
"DNB" <ii@ii.comwro te in message
news:Oz******** ******@TK2MSFTN GP04.phx.gbl...
>>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.

You can use SQL Server as a state server, which you set that up through
the Web.config, you set up SQL server to be a state server with the .Net
Utility that does configuration. Then you can make a serialized Session
object to hold you session object in session with the data or variables
serialized and saved and retrieved to/from SQL Server. .Net will keep
track and take care of what needs to be done by itself to keep all session
state. All you do is set and get the object.

Look it up use Google and find out how to keep session state using SQL
server as a state server.


Nov 29 '07 #6

"Peter Bromberg [C# MVP]" <pb*******@yaho o.NoSpamMaam.co mwrote in message
news:B2******** *************** ***********@mic rosoft.com...
You should consider (if Possible) getting all the data for a particular
user's session and store it in Session State.
As long as that is the information that is grabbed, sure. As I read this, he
was talking about prefetching the entire list of students when the initial
page was hit and storing that in session. Not a wise idea.

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

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

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

Similar topics

4
5694
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 userid in session, and then create queries. My sessions looks like this: uid|s:5:"admin";pwd|s:5:"test";
5
9609
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 the dbase while the user is browsing the site? Does this depend somehow on how many sessions are going on at once? Any input would be appreciated, thanks!
14
2595
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 create the object only when you actually use it. - Causes poor performance because the thread that created the object has to service all requests for it. Assuming I can live with the memory and performance implications (a big if,
2
1629
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 example, if I use session variables, can I have an admin utility that lets me see a list and/or count of all open sessions? Or would I be able to keep the same user from starting multiple sessions if I wanted (by comparing the log-in name which...
9
1800
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 corresponding overridable function. I've found 'register_shutdown_function', but apparently it detects connection breaks while the page is being loaded (I'm not sure though). I supose it will always be possible to control timeouted sessions by...
3
3059
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 customer/purchases database. A user creates an account and a database entry is added to a customer table. Once a user successfully logs in with a valid Username/Password I store away the UserID (which is the primary key of the Customers table) in the Session...
4
2197
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. The web farm is doing searches which are quite performance expensive against the ldap server, taking up to 10 or 15 seconds. The searches are displayed to the client in a datagrid, which then may have to be paged.
14
2251
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 have about 5 or 6 developers testing this web site in a staging environment on a Microsoft 2003 Server box. We have a base page that gets called on every page and checks for session variables. After about 20 - 30 minutes these session variables are...
3
1588
by: DNB | last post by:
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.
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7725
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.