• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1008
  • Last Modified:

Programatically create SQL Server CE 2000 database in C#

Hello,

Can anyone point me to a way to programatically create a SQL Server CE 2000 database (.sdf file) using C#.

Cheers

Andrew
0
andrewharris
Asked:
andrewharris
  • 3
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
Hi andrewharris,

SqlCeEngine engine = new SqlCeEngine("Data Source = C:\\test.sdf");
engine.CreateDatabase();

/*Connecting to a SQL CE database*/

SqlCeConnection ssceconn = new SqlCeConnection("Data Source = C:\\test.sdf");
ssceconn.Open();
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
0
 
andrewharrisAuthor Commented:
aneeshattingal my friend... you are a star! That worked a treat, just had to change C:\ to a valid Pocket PC path, ie \\Program Files\\TestApp\\, etc

And just to add for anyone else who looks for this, to password protect the database:

SqlCeEngine engine = new SqlCeEngine("Data Source='\\Program Files\\TestApp\\test.sdf'; Password='password'");
engine.CreateDatabase();

Cheers

Andrew
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
Ok.. Now you can close the Question ...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now