Database libraries, programming

theDot

2[H]4U
Joined
Jun 7, 2004
Messages
2,408
So I'm working on a project with a friend, and I'm trying to come up with the best and simplest solution as to how to store our data. The project involves storing tests, student data (including test scores, and their answers to the tests, etc.) and so on. I was thinking about just using straight text input/output for storing these, which would work fine for the level we're working at, but it's certainly not the most fun. I don't want to use something like an access database or something that requires a lot of overhead and preinstalled software on the end users computer.

Has anyone had experience with database libraries? (We're using C#) Are these lightweight enough? Compatible for a wide array of end users' computers? How hard are they to work with (coding, that is)?

Someone was reccomending... Berkeley DB?

I guess I'm just looking for any ideas, advice, or where to get started.

Or should I just stick with the text files...
 
Depending on the exact application, you could use MSDE (free version of Microsoft SQL Server) or, if you didn't want to have to install software, you could use an access database from c#. All you need to read/write to the .mdb file is MDAC(i think), which may or may not be installed (it's free to redistribute/download).
 
Also, if you were feeling lazy, you could just serialize a dataset to a file.
 
Definetly just use the Access tables. The users don't need Access installed, but like Earp pointed out, MDAC does need to be installed.

ADO.NET calls into Access tables are easy, easy. And multiuser locking is handled for you, using a file is going to have contention issues.
 
Is the only problem with writing to text files is that you don't want to do the reconstruction yourself? If so, I say go with Earp's second suggestion of serializing unless there is some reason that I don't know about that makes serializing a bad choice.

Databases seem to be overkill for something as simple as saving test scores in...unless you're going to run into some kind of synchronization problems?

Serializing is so easy. Most (if not all) of the Collections serialize, and it's possible to make your own classes serializable by just placing the tag [Serializable] in your class (or something like that; I'd have to re-read up on it)

Code:
Stream stream = new FileStream(@"c:\test.dat", System.IO.FileMode.Open);
System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
myArrayList = (ArrayList)formatter.Deserialize( stream );
stream.Close();

Code:
Stream stream = new FileStream( @"c:\test.dat", System.IO.FileMode.Create );
IFormatter formatter = new BinaryFormatter();
formatter.Serialize( stream, myArrayList );
stream.Close();
 
Back
Top