How can I create a new SQL Server Compact database file (.sdf) programmatically, without having an existing template file to copy from?
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 .
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.
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.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With