Tech Off Thread

12 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

What to use for local data storing?

Back to Forum: Tech Off
  • User profile image
    Stitch 2.0

    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?

  • User profile image
    UnkleMunkle

    If you're talking about whether it should be a class or a struct, then it should be a class because of its size.

  • User profile image
    Stitch 2.0

    Oh, sorry, I could have been more clearly... Smiley

    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....

  • User profile image
    littleguru

    Stitch 2.0 wrote:
    Oh, sorry, I could have been more clearly... Smiley

    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...

  • User profile image
    Tyler Brown

    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?

  • User profile image
    Stitch 2.0

    That sounds like a good idea.... I think I'll give it a try... Thanks

  • User profile image
    Stitch 2.0

    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

  • User profile image
    Sven Groot

    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).

  • User profile image
    Maurits

    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)

  • User profile image
    JoshB

    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.

  • User profile image
    littleguru

    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.

  • User profile image
    Blue​Firehawk02

    my vote is to put all objects in a collection and serialize it.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.