How to connect to SQL Server Ce database from C #?

How to connect Sql CE Db server to C # DotNet 4.0 I heard System.Data.SqlServerCe NameSpace to connect a local database, but I can not find it in .Net 4.0

is there an alternative class

+3
source share
6 answers

You need to enable namespace System.Data.SqlServerCe

AT System.Data.SqlServerCe.dll

If this namespace is not displayed, you may not have included refrence in this one dll.

Add a link to this DLL and it should be available.

If you still have a problem, check it out in the GAC . (On my system, its here:
  C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Data.SqlServerCe.Entity\v4.0_4.0.0.0__89845dcd8080cc91

Some answers already mentioned how to use it.

+8
source

System.Data.SqlServerCe.

SqlCeConnection conn = new SqlCeConnection("Data Source=\\Mobile\\Northwind.sdf;");
conn.Open();
.
.
.
conn.Close();

MSDN:

: System.Data.SqlServerCe

: System.Data.SqlServerCe( system.data.sqlserverce.dll)

+4

Visual Studio, NuGet. : Install-Package SQLCE

using System.Data.SqlServerCe;

:

using (var connection = new SqlCeConnection("someConnectionString"))
{
    //do stuff
}
+4

. Dll C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop

0

System.Data.SqlServerCe.dll .NET 2.0-3.5 GAC:

c:\Windows\assembly\GAC_MSIL\System.Data.SqlServerCe\4.0.0.0__89845dcd8080cc91\System.Data.SqlServerCe.dll

.NET 4.0 GAC (C:\Windows\assembly\GAC_MSIL), .NET- 2.0.

0

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


All Articles