tags:

views:

479

answers:

8

Complete newbie question here: I'm just playing with C# for the first time and want to make a Windows Forms application which stores some info in a database structure, but obviously don't want to require something like MySQL to be installed on each client's computer. How do I go about this?

A: 

Perhaps you could serialise a dataset and save it as XML. I'm a little confused why if you're playing around you would need to install MySQL on all client's computers. You could look at using SQL Express which is free perhaps?

Serialise Dataset:

http://blogs.msdn.com/yosit/archive/2003/07/10/9921.aspx http://msdn.microsoft.com/en-us/magazine/cc163911.aspx

MrEdmundo
+15  A: 

You can use SQLite. It doesn't require any installation or server on the client's computers. Here is an blog describing how to use it with .NET. It is easy to use, just add a reference to the System.Data.SQLite.dll.

Here is an open source data provider for .NET: System.Data.SQLite

From homepage: "SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain."

BengtBe
I can't recommend SQLite highly enough.
Galwegian
+1 this is *exactly* what SQLite is meant for
annakata
+6  A: 

You use a database that doesn't require an install. There are a few out there - there's Microsoft SQL Server Compact, which frankly is badly named, as it won't support the more useful SQL functions like stored procedures, views and so on. There's also VistaDB which does support stored procs, but requires purchase if you want Visual Studio plugins.

blowdart
+1  A: 

You could write your data to XML files, or you could take a look at the Sql Server Compact Edition.

You could also work with objects and serialize/deserialize these to disk as binaries.

Of course the type of storage you choose depends a lot on the kind of data you're storing (and the volume of it).

thijs
+1  A: 

Use SQL Server CE

Stevo3000
A: 

An easy way to do it from .NET 3.5 onwards is to store your data in XML files and use Linq to XML. This allows you to use SQL-like commands on your data which are actually compiled into your application, so you get full IDE IntelliSense support and error checking.

Matthijs P
+2  A: 

The answer is Embedded Databases. You've got quite a large list of Embedded databases that you can use:

Commercial:

  1. VistaDB - This database is written completely in managed C#.

Open Source:

  1. Firebird - .NET Driver
  2. SQLite - .NET Driver
Praveen Angyan
Interesting- didn't know about Firebird.
RichardOD
A: 

The Easiest way will be SQL Server Compact, Because it integrates directly into the Visual Studio IDE (I'm just hazarding the guess here that you use VS). Add the "Local Database", Create your tables and be sure to make your Table Adapter with Select, Update, Insert and Delete methods. If during Database Creation you called your Dataset "DS" you will be able to instantiate a Table Adapter Object from

DSTableAdapters

Namespace, and Use GetData() or Fill() methods to retrieve your Data, and Insert(), Update() and Delete() to Manage it.

wsd