How to create a SQL Compact 3.5 database for Windows Mobile in an ASP.NET web application?

In an ASP.NET web application, I need to dynamically create a SQL Compact 3.5 database for a Windows Mobile Compact Framework application from a data source (SQL Server).

I need to create a database file, the necessary objects (tables, ...) and populate the tables with data. The client application (Windows Mobile device) will download this generated file.

What prerequisites (assembly links, installations) do I need - or: is this possible?

+3
source share
3 answers

, . . SQLServerCE .

:

, :

AppDomain.CurrentDomain.SetData("SQLServerEverywhereUnderWebHosting", true)
+1

System.Data.SqlServerCe. GAC, DLL.

SqlCeEngine CreateDatabase()

CodeProject VB.NET.

+3

SQL Compact 3.5 SP1 Runtime:

http://www.microsoft.com/downloads/details.aspx?FamilyId=DC614AEE-7E1C-4881-9C32-3A6CE53384D9&displaylang=en

Then add a link to System.Data.SqlServerCe

Here is an example of code that creates a new database:

using System.Data.SqlServerCe;

public static class SqlCompactServices
{
    public static void CreateDatabase()
    {
        string connectionString = "Data Source=file.sdf";
        using (SqlCeEngine engine = new SqlCeEngine(connectionString))
        {
            engine.CreateDatabase();
        }

        using (SqlCeConnection connection = new SqlCeConnection(connectionString))
        {
            connection.Open();
            // preform queries just like "regular" SQL Server
        }
    }
}
-1
source

Source: https://habr.com/ru/post/1713326/


All Articles