CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2011
    Posts
    1

    Best way to save data in C#?

    I want to make a program that will allow the user to enter data into a set number of fields and then the program should store this data.

    However what would be the best way to save the data?

    Should I save it as a txt file or should I go the whole hog and try and learn about databases and all that?

    Thanks
    AL

    PS. I'm only a relative newbie to programming so I'm not sure about what to do.

    PPS. I'm using Visual Studio 2010

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Best way to save data in C#?

    To me, that depends on the data. Will you only ever need to use 1 or 2 sets of data? If so then files should be fine. If you users are going to store this data multiple times a day and want to pull up older sets of data, then a Database is best.

    That is the short answer. There are many other thing that go into deciding on where to store your data. Security, deployment ease of access are just a few.

    So, what are your plans with the data??

  3. #3
    Join Date
    Dec 2008
    Posts
    144

    Re: Best way to save data in C#?

    If you have a lot of data, then you need a database. LINQ to SQL makes working with databases very easy.

    If it's not a lot, then you have a number of different options for writing to files, or you can look into Serialization for saving data, user preferences, etc.
    Code:
    if (Issue.Resolved)
    {
         ThreadTools.Click();
         MarkThreadResolved();
    }

  4. #4
    Join Date
    Dec 2011
    Posts
    1

    Re: Best way to save data in C#?

    Another way you'd want to look at it is if the data you are trying to save needs to be accessed on a local machine or by another machine. If it's being used locally and there's not too much data, you should use files, probably being XML and INI (personal preferences.) If the data is being exchanged, edited on a website or if there is a server involved, you might want to use a database. (MySQL is the easiest, NHibernate I hear is one of the best yet hardest)

    Or you could always look at it from an organization standpoint. SQL is very easy to be organized if you know what you're doing, same with XML and INI again, if you know how to read the files. It all really comes down to preference and what sort of application needs to access data and how.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured