Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create SQL Server CE database file programmatically

How can I create a new SQL Server Compact database file (.sdf) programmatically, without having an existing template file to copy from?

like image 803
Andrew Arnott Avatar asked Sep 28 '09 15:09

Andrew Arnott


People also ask

How do I create a SDF file?

Right click on No SQL Compact Data Connections Found and select Add SQL Server Compact 4.0 Connection… A small window will pop up where you will enter your desired password. After your password has been entered, click Create at the top of the window where you will you will name your new .

How do I create a SQL .SQL file?

Right click on the database under Tasks click generate scripts and wizard will open and then you can export the table structure and data to another database. You have to select the tables and other schema you want to export and on one of the pages is a check box to select export table data.

How do I create a SQL database in Visual Studio?

Right-click on Tables and select Add New Table. The Table Designer opens and shows a grid with one default row, which represents a single column in the table that you're creating. By adding rows to the grid, you'll add columns in the table. Right-click on the CustomerID row, and then select Set Primary Key.


1 Answers

There is some good info here: Create a SQL Server Compact Edition Database with C#

string connectionString = "DataSource=\"test.sdf\"; Password=\"mypassword\""; SqlCeEngine en = new SqlCeEngine(connectionString); en.CreateDatabase(); 
like image 92
D'Arcy Rittich Avatar answered Oct 01 '22 08:10

D'Arcy Rittich