Data Storage in Windows Applications

clamum

Lifer
Feb 13, 2003
26,256
406
126
This is sort of a general question but I would like to get some opinions on how you guys decide how to store data for an application.

While a database like SQL Server is an obvious choice, what I'm more interested in is data storage for applications that are stand-alone on a user's computer and do not connect to any central server. Obviously not everyone has SQL Server or Express so you cannot use that to store data.

What other options are there? XML files would be easy enough to read/write but they do not seem suitable for larger amounts of data. Say you have a multiple generic Lists of different business objects that you'd like to store. Normally I'd write them to a database, but how would you store these without a database?

My working with data storage has been basically confined to databases so I do not have much experience with this sort of thing and would like to hear what others have done. What lead me to this question was an application I was thinking of writing in my spare time just for fun/learning where I would store keywords/tags of photos, like a photo album, but I was not sure how I would store/retrieve the data.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
I use IsolatedStorage in my C# apps. I dump XML files using it and have never had any issues with it. If you have a dataset made already it's trivial to dump to XML. Otherwise you can look into Serialization, which works with IsolatedStorage as well.

 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
For big data sets, I generally use open(), read(), write(). No fancy abstractions needed.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Depending on the complexity of the data, you can store it in a .mdb or any other ODBC format.

You do not need the Access front end for the .mdb
 

imported_Dhaval00

Senior member
Jul 23, 2004
573
0
0
We usually tend to do this [exchanging objects between applications and reconciling to a central repository over the wire] a lot, and serialization is usually the fastest. Nevertheless, there are versioning issues with complex object streams if the serialization graph hasn't been created properly. I have learned the hard way to always implement ISerializable - never had any issues since then.

Also, if you can use WCF, and have the liberty of having a connected backend, exchanging data between your backend and client executables will be faster. WCF will allow you to stream bytes of data which doesn't induce the overhead of verbose XML.

Otherwise, IsolatedStorage works best.
 

JasonCoder

Golden Member
Feb 23, 2005
1,893
1
81
Not heard of sqllite before but msft does have a tiny little version of SQL called SQLCE. Smart client devs love it because a) it's SQLServer and b) the sync framwork makes it a snap to move the data to the central server.

In your code you can use typed datasets, LINQ, EF or whatever you'd like to work with it.
 

clamum

Lifer
Feb 13, 2003
26,256
406
126
I think I've probably heard of SQL Server Compact before but never looked into it, but dang that looks great! I see it does not support stored procedures but for what I'm doing I probably would not use them anyway. SQLite looks pretty neat as well but I'd probably be more comfortabale with SQL CE since it's more like SQL Server. I will look into both though, thanks for the info.

I also did not know you could use .mdb database files without at least the Access Runtime, good to know.

About the IsolatedStorage, I haven't gotten a chance to read in depth into it, but it seems like it's geared more towards storing application settings on a per-user basis, basically a "improved" registry. Is this true? Or does it not really matter can you can use it to store all of the application's data (for all users)?

If it matters I'm interested in data storage with Windows .NET apps.