473,484 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using session object vs. module.vb

hello, i m new to ASP.NET, but have experience with VB6....i have a couple of questions about the use of a module and the decleration of public objects in the module vs the use of sessions

the main issue i am concerned with is performance....i would like to create a public object called Client, then i can set its properties from a Database, and have that object alive for the duration of the user's interaction with the system.....which helps me a great deal because i use the properties of the client object quite alot, i also want to create a public object of type Dataset that i can fill and test on from anywhere in the application.....however, i am concerned that as the system becomes more popular, and there are a number of concurrent users, that may be a strain on the server's memory to have global objects for each user....is this correct, or have i miss understood this?

in my search for answers, i have come across the use of session states, to hold objects or variables...is this better in terms of performance than using global objects, and if so, how can retrieve a specific property of an object stored in a session variable

any help would be appreciated, thank you very much

sameh
From http://www.developmentnow.com/g/8_20...ork-aspnet.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Dec 8 '05 #1
4 2149

"semsem22" <sa*********@yahoo.com> wrote in message
news:31**********************************@msnews.m icrosoft.com...
hello, i m new to ASP.NET, but have experience with VB6....i have a couple
of questions about the use of a module and the decleration of public
objects in the module vs the use of sessions

the main issue i am concerned with is performance....i would like to
create a public object called Client, then i can set its properties from a
Database, and have that object alive for the duration of the user's
interaction with the system.....which helps me a great deal because i use
the properties of the client object quite alot, i also want to create a
public object of type Dataset that i can fill and test on from anywhere in
the application.....however, i am concerned that as the system becomes
more popular, and there are a number of concurrent users, that may be a
strain on the server's memory to have global objects for each user....is
this correct, or have i miss understood this?

in my search for answers, i have come across the use of session states, to
hold objects or >variables...is this better in terms of performance than
using global objects,
Global objects are just wrong for this. Global objects are not limited to
the user's session. They are shared across all user sessions. The session
object is what you want. Some care must be taken with stuffing data into
the session state, but when you divide the available server memory by the
maximum number of concurrent sessions you will often find that this is not
really an issue (especially now that .NET 2.0 lets you run your web site on
64-bit machines).
and if so, how can retrieve a specific property of an object stored in a
session variable


Session is basically a Hashtable, so you stuff something in with a key:

Session("UserProfile") = MyUserProfileObject

And pull it back out using the same key

dim MyUserProfileObject as MyUserProfile =
DirectCast(Session("UserProfile"),MyUserProfile)


David
Dec 8 '05 #2
thank you very much for your reply, however i am wondering what this
code does

DirectCast(Session("UserProfile",MyUserProfile)

what does DirectCast do for session object

thank you
sam

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Dec 8 '05 #3

"semesm22" <sa*********@yahoo.com> wrote in message
news:%2********************@TK2MSFTNGP11.phx.gbl.. .
thank you very much for your reply, however i am wondering what this
code does

DirectCast(Session("UserProfile",MyUserProfile)

what does DirectCast do for session object

dim MyUserProfileObject as MyUserProfile =
DirectCast(Session("UserProfile"),MyUserProfile)

This extracts an object of type MyUserProfile (which you would have to
write) from the session object. When you pull it out of session it is
upcast to an Object. DirectCast downcasts to the MyUserProfile type before
assigning it to the variable. If you turn OPTION STRICT off the DirectCast
is not needed.

David
Dec 8 '05 #4
i would like to do the following....i have a ConnectDB class, that
imports system.data.ole, and i have the OleConnection, and OleCommand,
and a SQL string as a property in that class....the idea is that i can
set the SQL property from any web form, and call a login method that
will connect to the datebase and select * from client, for example, and
put the data in a Dataset.....what i would like to do is to add this
dataset to the session object, so that i can check to see if there were
records found in the database from the web form that called the Login
method...here is the code i m using, cause i don't think i'm explaining
this well!!!

public class ConnectDB

*** i nitialize the connection string, and the OleConnection,
OleCommand, and DataAdapter here***

public sub Login()

'SQL statment set from any page
OleCommand.CommandText = me.SQL
OleCommand.Connection = OleConnection

try
OleConnection.Open
dim myDataset as new Dataset
DataAdapter.Fill(myDataset)
catch
end try
end class

************************************************** ***********
now what i would like to do is to assign myDataset to a session
object....is this even possible?, if so, how can i do that? if not, then
what is a better solution?
************************************************** **********
public class WebForm1

private sub Login_Click()

dim myConnectDB as new ConnectDB

myConnectDB.SQL = "select * from client where name = '" & txtName.text &
"'"
myConnectDB.Login

end class
PLEASE HELP
thank you
sam

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Dec 8 '05 #5

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

Similar topics

1
2009
by: Scott Wickham | last post by:
I'm having a problem saving session information on one form and retrieving it on a subsequent form...for only one out of a number of users. Actually, I'm not absolutely certain it's a session...
2
2373
by: Boban Dragojlovic | last post by:
I'm building a complex web-based reservations system. Gathering the user's data requires between 8 and 15 pages (depending on which options they are interested in). I use the "Session" object to...
4
3897
by: Danny W | last post by:
Hi There! Is it possible to use HttpModule to replace the built-in ASP.NET Session object? I want to write a HttpModule that will handle storing and retrieving of session values from an external...
9
3162
by: Randy | last post by:
Hello, I'm having a strange problem. I've got a .NET web app which uses Session variables. Sometime, not all the time, they get cross threaded...that is...one user will have another user's Session...
3
1556
by: MrShovel | last post by:
I'm new to this ASP.NET caper and have the following questions. I have a TestObject that contains about 50 fields of data and 3 member procedures. Below is a simplified explanation of what I do....
5
1423
by: Steve Mauldin | last post by:
Having weird things happening with my code. Two users on at the same time and data entered by one user is added into another users global variable. global variable data being stored in session...
2
1835
by: momo898 | last post by:
I have a big problem. Most case it's working well but sometime the below happens. User A on computer B gets session object created by user X on computer Y instead of getting session object saved...
6
1909
by: Joseph I. Ceasar | last post by:
I have an ASP .Net 2.0 site that I am working on. It has a master page and a content page. I also created a separate class module that returns a DataSet to feed my GridView. So far, so good. ...
4
2505
by: Cirene | last post by:
In my web.config I added <pages enableSessionState="true">. In each of my pages I also added EnableSessionState="True" to the Page declaration. (I didn't think this was necessary, but...) ...
0
7103
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
7137
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6809
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...
0
7194
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...
1
4838
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
4527
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...
0
3038
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1355
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
587
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.