tags:

views:

106

answers:

6

Apologies if this is a very basic question, but I am preparing to create an executable for a Visual Studio C# Application. (My first time!)

My application uses a database that I'm currently storing in SQL Server. This works fine while I'm coding since I created the database manually on my computer.

I see that VS2008 has created an .exe in my bin/debug folder, but how do I ensure that any new users (that doesn't already have the database) doing a fresh install gets the database also?

+2  A: 

Take a look at Embedding SQL Server Express into Custom Applications

Christopherous 5000
Thanks! Will review these instructions to implement this!
DevX
A: 

You would need to create an installer that builds and installs the database. You could do this by maintaining scripts containing code to create the database, tables, stored procedures, views, data, etc. Then the installer can run these scripts to detect if the database is present, and if not, create the database and run the scripts to build it out and populate it.

One of the advantages of this approach is that since the database scripts are just text files on disk, you can store them in source control and check in changes, etc.

Depending upon your needs, you may also need to allow for the possibility of upgrade scripts, to upgrade a database that is already deployed.

Justin Ethier
A: 

If you need advanced database procedures, SQL Server Express is the thing you want to embed as suggested by another poster. If you're just using it as a basic data store, you may find it easier to use SQLite instead which is bundled by just referencing a single .DLL in your assembly.

eftpotrm
+1  A: 

You can embed SQL Express and distribute the MDF file or run script to create the db schema and basic data set.

Depends on the type of application that you are creating, if it is a simple app, you can consider using SQLite and the distribution will just be the database file and it requires no db server installation or configuration. In case you worry about the complexity of it, you can access SQLite using ADO.NET as well LINQ through .NET libraries that you can download.

Fadrian Sudaman
I've heard about SQLite a few times. Seems like I need to check it out. As long as LINQ works with it I'm good!
DevX
A: 

If you're looking for an embeddable database (each user gets their own database alongside the app) I've personally used System.Data.SQLite on a desktop app, and can recommend it. It's a .NET wrapper of SQLite, a public domain database engine you embed directly into your app. The database lives in a single file.

Matthew Flaschen
A: 

I recommend FirebirdSQL Embedded Server. High performance, lots of features, comparable to MSSQL Express Edition. And it's only a few DLLs in the application folder.

Alexander