Stay alive, data! Where to put datasets for global access? 
June 30th, 2009, 08:41 PM
| | Newbie | | Join Date: Dec 2008 Location: Bloominton, CA
Posts: 30
| | |
I think I've somehow missed a basic design principle for storing data from databases.
What is the "correct" way to store data that your whole application needs access to, regardless of which forms are open or which class is reading the data? I would like to store datasets apart from forms, but don't know how to create them in their own space so that they can be referenced in code at design time.
When I started programming, I was using the AppDomain for everything but realized that it isn't designed for holding a whole database. I use per-table SQL Select statements when I need to load data, am extending my subs to also do per-ID-range SQL Selects for reloading chunks of a table, and the AppDomain doesn't work the way I though it did.
My other idea is using My.Settings to store datasets, in addition to configuration options. Would that work? I wouldn't want to keep the datasets when closing the program.
| 
July 1st, 2009, 05:52 AM
| | Moderator | | Join Date: Dec 2007 Location: India
Posts: 691
Provided Answers: 1 | | | re: Stay alive, data! Where to put datasets for global access?
You can use Cache to store your dataset. -
DataSet ds;
-
//Fill DataSet
-
-
Cache["globalDS"] = ds;
-
-
DataSet ds1 = Cache["globalDS"] as DataSet;
-
//OR
-
ds1 = (DataSet)Cache["globalDS"];
-
| 
July 1st, 2009, 02:34 PM
|  | Forum Leader | | Join Date: Apr 2008 Location: San Antonio, TX (USA)
Posts: 2,569
| | | re: Stay alive, data! Where to put datasets for global access?
PRR, that will only work if he is using ASP.NET.
I'm guessing that you're using VB.NET? You could define the DataSet as a Shared property of the class that loads the data.
| 
July 1st, 2009, 02:49 PM
| | Moderator | | Join Date: Dec 2007 Location: India
Posts: 691
Provided Answers: 1 | | | re: Stay alive, data! Where to put datasets for global access?
Yes, i assumed the application would be asp.net. Shared/Static DataSet would do the trick... thanks for pointing out :)...
| 
July 1st, 2009, 03:36 PM
| | Newbie | | Join Date: Dec 2008 Location: Bloominton, CA
Posts: 30
| | | re: Stay alive, data! Where to put datasets for global access?
Thank you! Yes, I'm using VB.NET.
Aha! so THAT is what shared means. :) Making my datasets part of a module or shared class should do the trick then.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|