Session variables or DataSet Table

A

asadikhan

Hi,

I have a table in my database called users which contains user
information like their login id, password, first name, last name,
phone, etc. Once I retreive this information, I'd like to hold it in
memory. One obvious way of doing this is session variables. However, I
am thinking whether usign a Dataset would be more suitable in this
situation. If I create a table called "user" and store the user's
information in that table (it would have only one row with the user's
information) would that be a good way of doing this? (I have a feeling
it won't be, but I can't reason why).

I guess what I am fuzzy on is whether the dataset object is held in
memory and would be accessible throughout the application. Or would I
have to declare my dataset as a global object somewhere (where would I
do that?)

I would appreciate it if someone could help me think clearly about
this.

Regards,

Asad
 
P

Peter Rilling

Simply having a dataset in a variable does not mean it will live beyond the
current page request. You still would have to add it to a session variable
to be maintained. Datasets have a lot of overhead with them because their
primary storage medium is XML (I think).

What I would do is to create some class that has that information and store
that class in the session variable.

For instance,

public class User{
public string Name{
get{return m_name;}
set{m_name = value;}
}

...
}
 
A

asadikhan

Makes perfect sense, thanks.

Just one clarification though, you mean you would add an object of this
class to session right? Not the entire class (I don't even know how you
could add a class to a session).

Asad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,174
Latest member
BlissKetoACV
Top