PC Review


Reply
Thread Tools Rate Thread

asp.net Session vs Database Queries

 
 
DNB
Guest
Posts: n/a
 
      28th Nov 2007
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


 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      29th Nov 2007

"DNB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.


 
Reply With Quote
 
Som Nath Shukla
Guest
Posts: n/a
 
      29th Nov 2007
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
>
>
>

 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      29th Nov 2007
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
>
>
>

 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      29th Nov 2007
ANSWERED in ASP.NET group.

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

*************************************************
| Think outside the box!
|
*************************************************
"DNB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>



 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      29th Nov 2007
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. (E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "DNB" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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.
>
>



 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      29th Nov 2007

"Peter Bromberg [C# MVP]" <(E-Mail Removed)> wrote in message
news:B2B0117A-5B52-4A9E-9DFD-(E-Mail Removed)...
> 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!
|
*************************************************


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Asp.Net session vs. Database Queries. DNB Microsoft ASP .NET 3 29th Nov 2007 04:15 PM
SQL Session Database Name? =?Utf-8?B?QmlsbDQ0MDc3?= Microsoft ASP .NET 3 23rd Mar 2007 07:16 PM
SQL Database Mirroring and the Session State Database Calculated Microsoft Dot NET 1 20th Sep 2006 05:05 PM
DataBase Connection in Session Francisco Spaeth Microsoft ASP .NET 2 19th Sep 2005 03:09 PM
preventing tables and queries to be imported from a database to another database ? Zlatko Matiæ Microsoft Access 3 20th Jun 2005 02:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 PM.