Hi everyone,
I'm starting to work on a small project at home and I just can't decide what to use for data storing....
What needs to be stored?
- object id
- object name
- object desc
- a time period
- id of another object
- a couple of boolean values
So, can anyone give me an idea of what's best to use?
-
-
If you're talking about whether it should be a class or a struct, then it should be a class because of its size.
-
Oh, sorry, I could have been more clearly...

I ment storing the data on the HD. Like, when the prog is closed.
My Problem simply is, that I have almost only written Client/Server apps up until now, working with large Oracle DB's.... -
Stitch 2.0 wrote:Oh, sorry, I could have been more clearly...

I ment storing the data on the HD. Like, when the prog is closed.
My Problem simply is, that I have almost only written Client/Server apps up until now, working with large Oracle DB's....
You could seralize the object (the list that contains the settings) and save it as xml file... -
It also depends on the amount of data that will need to be stored. If there are thousands of objects... then perhaps you would be best to stick with the Oracle database?
-
That sounds like a good idea.... I think I'll give it a try... Thanks
-
No, there probably won't be more than maybe 20-30 objects to store.... plus some settings
So I think the seralization sounds like the best option....
Thanks again -
Serialization is definitely a good option, but do also give some thought as to the location. Is this per-machine or per-user data? In the former case, use the "All Users\Application Data" folder, which you can get by using Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData). In the latter case (per-user) you could use the Application Data or Local Settings\Application Data (depending on whether the data should roam or not), which can be retrieved with Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) (roaming) and Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) (roaming). Better still, use IsolatedStorage (the classes in the System.IO.IsolatedStorage namespace).
-
You could store info in:
A text file
The registry (small datasets only)
A SQL database (MSDE, MySQL, Access, etc.)
EDIT: another option just occured to me - you could put each object in their own text file, then use file locking to support a per-object means of serialization (which could be useful if locking collisions become a problem) -
I usually will create a datatable to store my objects. When the app is closing I'll dump the table out as XML and when the app is loading I'll read the xml file back in.
I like this way because you get a lot of features for free with the datatable such as ordering and filtered selection.
As with the serialization post above, keep the xml outputs in a shared directory if necessary.
-
JoshB wrote:I usually will create a datatable to store my objects. When the app is closing I'll dump the table out as XML and when the app is loading I'll read the xml file back in.
I like this way because you get a lot of features for free with the datatable such as ordering and filtered selection.
As with the serialization post above, keep the xml outputs in a shared directory if necessary.
When serializing an ArrayList or List<T> (Whidbey) to XML you have also the possiblity to sort the reloaded objects... You don't need a DataTable.
I like the XML (SOAP) serialization mechanism that is build in the .NET framework. It's easy to use and the result is very good. -
my vote is to put all objects in a collection and serialize it.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.