Programmatically adding table to Microsoft SQL Server Compact 3.5 Database
Asked Answered
T

1

6

We want to add a table programmatically to our local stored Microsoft SQL Server Compact 3.5 Database. The code below creates the 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 is working fine, but the table isn't listed up in the Server Explorer of the specified database table. We can insert values into the table and read data out of the table.

Do you know any solutions for this problem?

Afterwards we want to add a dynamic datamodel, which we want to use as a provider of our tables.

Thank you in advance.

Timber answered 24/10, 2012 at 13:20 Comment(2)
Please format your code when asknig questions; it makes it easier to read.Curiosa
If I'm correct, the VS 2010 does not support CE table listening. Use e.g. CE Query from codeplex, or another tool.Chayachayote
P
2

The use of |DataDirectory| means that you have 2 copies of the file in your project folders.

Your application is using the one in Root\bin\debug.

Your tools are looking in \Root.

Panorama answered 24/10, 2012 at 13:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.