473,609 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ 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.....whic h 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 2159

"semsem22" <sa*********@ya hoo.com> wrote in message
news:31******** *************** ***********@msn ews.microsoft.c om...
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.....whic h 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("UserPr ofile") = MyUserProfileOb ject

And pull it back out using the same key

dim MyUserProfileOb ject as MyUserProfile =
DirectCast(Sess ion("UserProfil e"),MyUserProfi le)


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

DirectCast(Sess ion("UserProfil e",MyUserProfil e)

what does DirectCast do for session object

thank you
sam

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

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

DirectCast(Sess ion("UserProfil e",MyUserProfil e)

what does DirectCast do for session object

dim MyUserProfileOb ject as MyUserProfile =
DirectCast(Sess ion("UserProfil e"),MyUserProfi le)

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.....wha t 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.Comm andText = me.SQL
OleCommand.Conn ection = OleConnection

try
OleConnection.O pen
dim myDataset as new Dataset
DataAdapter.Fil l(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.Log in

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
2018
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 problem but I'm hoping the experts can help me figure that out. Our application uses a session variable to "pass" info from one form to the next. It has always worked fine for our users until a few weeks ago when one of our users started having a...
2
2380
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 store the various elements as the user moves through the pages. Rather than storing the preferences directly in the Session object (e.g. Session("LastName") = ...), I created a class <Serializable()> Public Class ReservationInfo
4
3907
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 database. For example, when a page set values to Session object such as Session("somevar")=1 then I want my HttpModule to get notified and store the value into the external database. The same for "getting" the variable, I want my own...
9
3181
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 variable(s) data assigned to them. I can't figure out why. I've read that other people are having this problem too but I haven't found a resolution yet. Can someone please tell me how I might go about fixing this? Thanks
3
1567
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. At the start of each session I initialise this TestObject. On entering every page I create a local TestObject and do this: TestObject = Session("TestObject")
5
1430
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 variable between pages. any ideas?
2
1843
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 by User A. It means Session ID is changed. Is it possible? Have anyone seen this? Server is windows 2003.
6
1917
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. The thing is that the method that returns the DataSet is computationally expensive and I really need to create the whole DataSet only once per session. Once it's created, I'd like to return the same DataSet to the GridView for operations such as...
4
2510
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...) Any reason why even though I did this I keep getting this error.... Server Error in '/abc' Application.
0
8065
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
8563
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
8210
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
8394
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6990
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...
0
5507
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4013
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...
1
1656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1379
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.