Cannot find namespace 'System.Data.SqlServerCe'
Asked Answered
B

6

25

I did include the System.Data.SqlServerCe dll, put using System.Data.SqlServerCe; in my code, but when I open the .NET page I get:

The type or namespace name 'SqlServerCe' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

I have nave no idea how to fix this. Thanks in advance.

Bib answered 15/7, 2012 at 16:36 Comment(0)
M
26

This can be solved confirming following 2 points:

  1. Check whether you already have System.Data.SqlServerCe namespace added to the References folder of your application. If its not there you may right click the References folder and select Add references option. From the popup window go to .Net tab and select System.Data.SqlServerCe from the list and click OK to add the namespace to the project.
  2. If you are OK with step 1, add using System.Data.SqlServerCe; to the top of your code behind file which uses the System.Data.SqlServerCe namespace.
Mariettemarigold answered 15/7, 2012 at 16:53 Comment(2)
If you do not see that Reference in the standard list, browse to C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Desktop and select it from there.Driggers
You can also get System.Data.SqlServerCe v4 through the NuGet package "Microsoft.SqlServer.Compact" at nuget.org/packages/Microsoft.SqlServer.CompactGag
C
15

If you have an existing reference to System.Data.SqlServerCe yet you see a yellow symbol next to it then you should:

  • Remove the reference by right-clicking it.
  • Re-Add the reference.

To Re-Add: Right click the References folder and select Add Reference... option. Go to the Assemblies | Framework option on the left pane, then scroll to System.Data.SqlServerCe in the right pane. If it's there, click it then be sure to check the checkbox next to it before clicking OK.

If System.Data.SqlServerCe is not in the list then you're going to have to browse for it on your computer. To do that, click the Add Reference... dialog's Browse... button and try looking in this folder:

C:\Program Files\Microsoft SQL server Compact edition\v3.5\Desktop

or

C:\Program Files\Microsoft SQL server Compact edition\v4.0\Desktop

(The v#.# value in the examples above might be different by the time you read this, so navigate first to C:\Program Files\Microsoft SQL server Compact edition\ then choose the latest version or a specific version if you know what that should be.)

Once you find it by browsing, select the System.Data.SqlServerCe.dll file and OK your way out then try recompiling.

Caricature answered 25/8, 2016 at 13:11 Comment(0)
P
3

Installing SQL Compact Server and then adding that reverence system.data.SqlServerCe.dll directly from your Microsoft Compact DataBase/ Program folder.

You're missing the dll.

Im sure you already figured this one out though.

Paperboard answered 22/11, 2012 at 12:14 Comment(0)
T
1

Check your web.config file for any reference to that, and correct it. It could be an alias you defined wrong.

This answer might solve your issue.

Thermae answered 15/7, 2012 at 16:38 Comment(4)
How do I add this? I've tried: <add assembly="System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> it returns Could not load file or assembly 'System.Data.SqlServerCe, Version = 3.5.1.0, Culture = neutral, PublicKeyToken = b77a5c561934e089' or one of its dependencies. The system can not find the file specified.Bib
Look at @nvrtheless's answer. Have you added a reference to the dll?Thermae
See -> #936855 . Should solve your problemThermae
Verify the rest of your web.config file to make sure you are not re-declaring the namespace in a conflicting manner.Thermae
E
0

This is pretty late for answer. But I also faced the same kind of problem.
I am using Visual Studio 2012 and Visual Studio 2017 and I found the System.Data.SqlServerCe here.
The same directory for both Versions.

I edited @JesiMov Answer.

Right click the References folder and select Add Reference... option.
Go to the Assemblies | Extensions option on the left pane, then scroll to System.Data.SqlServerCe in the right pane.

Edessa answered 17/10, 2018 at 1:40 Comment(1)
i didn't find it in my vs 2017 witch .net version you use ?Venetian
P
0

use NuGet as simple

NuGet\Install-Package Microsoft.SqlServer.Compact -Version 4.0.8876.1

Paltry answered 17/10, 2023 at 5:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.