开发者

Best Method For Storing Values

开发者 https://www.devze.com 2022-12-19 21:10 出处:网络
Basically, I want to have a database that\'s lightweight and I won\'t need to install a million other things on my clients computers for them to access this.

Basically, I want to have a database that's lightweight and I won't need to install a million other things on my clients computers for them to access this.

I just need a simple method of reading and writing values so that they're not hardcoded into the program. I could do MySQL (which is what I'm very familiar with), but it doesn't need to be making calls remotely.

I woul开发者_如何学JAVAd have less than 10 fields and one table, if that matters. Thanks!


XML would probably be the simplest option, and is completely built into the framework (no extra dependencies). Here's some sample XML parsing code for VB.NET.

SQLite is a good, very lightweight alternative if you want a "database" like MySQL (although lighter, and a bit more restricted, but for 1 table, it probably doesn't matter).


If it's over .NET, what about Isolated storage?


If you're just talking about configuration, simply use the Settings feature of .NET. Use Add New Item to add a Settings file to your project, edit it and add the kind of values you want. You'll get strongly-typed configuration values with no coding.


Depending on who can access those configurations/settings/savings, I would suggest these options:

  1. local XML-file or similar format file in the folder with the program
  2. local ASCII file, where each line begins with a "label", then a delimiter charcode like ":" and then the value
  3. small SQLlite database, a bit more SQL like, but much more work to do
  4. the local registry on the users PC

Different pros/cons

  1. +very easy to edit (while developing), - bad for security as the user could tamper content easy, you have API support for reading XML, but format must follow XML

  2. same as XML, but no API support, but its quite flat, so less parsing might be needed. Just read every line into a large array and overwrite file when saving

  3. SQLlite is a bit more protected as it is a SQL database, but filebased, so this can only be opened by one program at a time. You cant share it between two programs at the same time.

  4. Registry is accessable through API, but this is "hidden" inside windows, so if you move the program, you loose the settings unless you make some sort of "backup/transfer" option. Clever users might know how to open RegistryEditor and try to export and import them manually, but normal users will have trouble.

So... depending on your use and security level, you could choose from those above.

Lastly, if you have a webserver running and think these programs should access internet, its farely easy to build a webservice which will allow you to save and load from an internetaddress too. Problem arise when the user is offline. What settings will you use then.

0

精彩评论

暂无评论...
验证码 换一张
取 消