Programmatically adding a table to a Microsoft SQL Server Compact 3.5 database

We want to add the table programmatically to our local Microsoft SQL Server Compact 3.5 database. The code below creates a table.

using (SqlCeConnection con = new SqlCeConnection("Data Source=|DataDirectory|\\Database.sdf")) { con.Open(); using (SqlCeCommand com = new SqlCeCommand("create table test (id int not null)", con)) { Console.WriteLine("Response: " + com.ExecuteNonQuery()); } con.Close(); } 

The code works fine, but the table is not listed in the server explorer of the specified database table. We can insert values ​​into the table and read data from the table.

Do you know any solutions to this problem?

Subsequently, we want to add a dynamic datamodel that we want to use as a provider of our tables.

Thanks in advance.

+6
source share
1 answer

Using |DataDirectory| means that you have 2 copies of the file in the project folders.

Your application uses one in Root\bin\debug .

Your tools look in \Root .

+2
source

All Articles