Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a session variable dataset from an application datase

Status
Not open for further replies.

yongbum

Programmer
Dec 15, 2005
48
IL
Hi
I have an asp.net app. using an sql server database.
What I want to do is create an Application Variable to contain the database - an Application Dataset. Then create a Session Variable Dataset for each user with data filtered from the Application Dataset according to the users login details (there are no changes to the database for the life of the application).
How do I set up these variables? any coding examples or pointers to tutorials appriciated.

Thanks
 
To add an application variable, use:
Code:
Application.Add
and to add a session variable, use:
Code:
Session.Add
To filter on a DataSet, use the Select method of the relevant DataTable.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
You can also use a DataView to filter the data, but I wouldn't store it in Session, rather you'd want to store the filter string in Session, or better yet, associate the filter string with the user's role and store one filter string per role (as a static variable somewhere or something).

That said, I'd actually worry about an Application-level DataSet because its instance methods are not guaranteed to be thread-safe. You may (or possibly may not) have to do some manual synchronization work to make it stable or use a different data store.
 
Thanks for your replies, I'm new to all this so if you know of any good tutorials on the subject I'd appriciate it.
I was wondering if instead of using application variables would using the cache be a better alternative?
 
It really depends what and how much data is needed. In some cases it makes better sense to just connect to the database when and if data is needed; in others it's better to cache the data. Unfortunately, only you know your application so you will have to decide which option uses the least resources and gives the best response.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Please can you give me some indication of the criteria I need to decide which methode is best.
My database consists of 4 tables each table contains 3 columns an integer, a date and a short string Char(16), I have a total of 350,000 records, each user will retrieve about 100 records. The database is static for the life of the application, it's updated once a month at which point the application will be stopped and restarted after the database has been updated.
 
You'll have to look at the time taken to retrieve data from the database, memory usage on the server, number of users, traffic etc


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
CAN SOMEONE PLEASE GIVE ME A CLEAR ANSWER AS TO THE SIZE LIMITATIONS OF USING APPLICATION VARIABLES OR DATA CACHEING.
IS IT REASONABLE TO KEEP THE WHOLE DATABASE RESIDENT IN SERVER MEMORY OR SHOULD I MAKE THE ROUNDTRIP TO SQLSERVER FOR EACH USER ?
 
Please don't use CAPS LOCK as it looks like you are SHOUTING!

As for a clear answer, that's hard to give as it depends on lots of factors (i.e. what we've mentioned above). There is no simple Yes or No answer to your question...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top