SQL CE db creation with C#
you can use the code and fill the datas from the existing MDF to CE.
if (!File.Exists(\My Documents\EmpDB.sdf))
{
SqlCeEngine empEngine = new SqlCeEngine("Data Source = \My Documents\EmpDB.sdf");
empEngine.CreateDatabase();}
Note : the database file name must have .sdf extension
SqlCeConnection empCon;
SqlCeCommand empCom;
empCon = new SqlCeConnection("Data Source = \My Documents\EmpDB.sdf");
empCon.Open();
empCom = empCon.CreateCommand();
string strQuery = "CREATE TABLE Employee (EmpID int IDENTITY(0,1) PRIMARY KEY,EmpName nvarchar(10),Salary int)";
empCom.CommandText=strQuery;
empCom.ExecuteNonQuery();
This code snippet create a table with three columns ( empid,emp name & salary )
string strQuery = "SELECT * FROM Employee ORDER By EmpName ASC";
empCom.CommandText = strQuery;
SqlCeDataReader empReader = empCom.ExecuteReader();