tags:

views:

90

answers:

2

I have a few questions regarding Compact SQL. I am using VS C# 2008 Express by the way.

1) Are there any GUI tools for creating and managing the databases?

2) Once the DB is created, and the app is released, would the app have to create the database each time the user installs it? Or can I create the database and include it with the app? I ask because the database will never change, but the data included is large.

3) Are relationships possible with SQL CE i.e. Forign Keys, 1 to many ...

+2  A: 
  1. SSMS Express is a free download. It is the Sql Server Management Studio from microsoft.

  2. You can bundle SQL Express with your application if needed and setup the database as part of installation.

  3. "SQL CE supports transactions, referential integrity constraints" - from WikiPedia.

Oded
Regarding question 2, if needed can I bundle a pre populated and only provide read access to the database? I was tempted to use an XML file, but because of the size of it, it's probably better to use a DB for easier management.
James Jeffery
You can always use the embedded DB bundled with current windows releases. ESENT, it has a managed interface: http://www.codeplex.com/ManagedEsent
Oded
awesome stuff. ESNET looks perfect!
James Jeffery
+3  A: 

1 & 3 answered by Oded.

2) I include an empty SQL Compact Edition Database as a emended resource. When it's time to create the Database I use this code:

using (FileStream fs = File.Open(fileName, FileMode.OpenOrCreate))
{
    BinaryWriter sw = new System.IO.BinaryWriter(fs);
    sw.Write(Template.TemplateDatabase); // Autogenerated: the Embedded Resource
    fs.Flush();
    fs.Close();
}
Arthur