SQL Compact C# .... Couple of Questions
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 ...
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();
}
SSMS Express is a free download. It is the Sql Server Management Studio from microsoft.
You can bundle SQL Express with your application if needed and setup the database as part of installation.
"SQL CE supports transactions, referential integrity constraints" - from WikiPedia.
精彩评论