Chris
Chris

Reputation: 7621

Storing data in WinForms applications

This is probably a very basic question, but I'm in the process of making a Windows Forms based application, which will involve a hefty amount of data storage. It will essentially be a sports simulator where there'll be hundreds of teams, with thousands of players.

So I need to figure out the best way to store this data. Windows Forms is relatively new to me as I've been mostly working with ASP.NET, but I've come up with the following ideas:

  1. Compact SQL database in the program directory
  2. Files containing the serializable objects.

Are there any other solutions out there that may be better? Or which of these should I pick?

Upvotes: 4

Views: 3154

Answers (3)

MAW74656
MAW74656

Reputation: 3549

Could use an .MDB Access database to store the data. Not as reliable in my experience as SQLite.

Also, you don't mention if you need to persist these data after the form closes? If you don't you may just want to use in memory DataSet's (or DataTables) to keep the data quickly accessable.

Upvotes: 0

Dour High Arch
Dour High Arch

Reputation: 21722

Your requirements are extremely vague, but in general stay away from serialization for any kind of persistent data store.

If your data is relational (it has internal structure, such as "teams must contain players" or "a player can be a member of only one team") then I suggest a relational DBMS such as SQL Server Compact Edition or SQLite.

If your data is not relational, I suggest a key/value store like RavenDB.

Also, do not put data in the program directory; it may not be writable by the user. Store data in the user directory.

Upvotes: 2

StuartLC
StuartLC

Reputation: 107387

If you have any need to execute queries against the data, I would stay away from serializing it in a proprietary format.

If there is only one user, then you could do something simple like an Access MDB via the JET drivers, SQLLite or NoSQL.

If there are going to be multiple concurrent users, you'll almost certainly need to look at a 'server' based SQL - e.g. SQL Express (although note the DB Size limitations), MySQL etc.

Upvotes: 1

Related Questions