views:

80

answers:

5

Hi

I am going to develop a Windows application in .net and I will be string few values. (A max of 20 values).

What is the best way of storing this? Using SQLIte seems to be a overkill.

My.Settings seem to forget the values sometimes.

What is the best way of storing these values?

is XML okay?

A: 

If you considered scalability and are 100% positive that it's only going to be a max of 20 values, and the nature of the values is such that you could store in an XML file you should explore storing them in the App.config (or Web.config) of your application. Or store them in an external XML file of your choice if you wish - .NET has extensible support for manipulating XML files so the overhead is minimal in the case of a few records.

But if you think that your application may evolve and need to store more values in the future, or you want to provide some access restrictions to the values, then you should look into using some form of database. It's just better in the longer run..

Miky Dinescu
A: 

XML is fine but even a plain text file in some delimited format is ok, for few records.

Nick D
A: 

Ugh. Avoid XML where you can, and where the data you're storing has no hierarchical relationship to each other. Use key-value properties like Java properties instead.

key1: value1
key2: value2 is longer
key 3: this is value3 for key3.

Simpler, more efficient than loading up an XML parser.

Chris Kaminski
But the OP would have to write the parser, would they not? With XML, most of the dirty parsing code is already provided by the .Net library.
Charlie Salts
Really? infile.readline(); key=str.substr(":"); 10 lines of code tops, where I've never written any XML parsing code in less than that. Then again I find JAXP extremely verbose at times and dom4j isn't much better.
Chris Kaminski
+2  A: 

I'd recommend creating a custom class to hold the data, and using a generic List to manage the collection. Serialize/deserialize that to/from XML and voila - storage and strongly typed data.

overslacked
A: 

You can always save values in the Windows Registry using the SaveSetting, GetSetting, DeleteSetting functions. They use the 'HKEY_CURRENT_USER\Software\VB and VBA Program Settings' registry key.