找不到命名空间'System.Data.SqlServerCe'

时间:2021-06-10 22:42:36

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:

我确实包含了System.Data.SqlServerCe dll,使用System.Data.SqlServerCe;在我的代码中,但是当我打开.NET页面时,我得到:

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

命名空间'System.Data'中不存在类型或命名空间名称'SqlServerCe'(您是否缺少程序集引用?)

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

我不知道如何解决这个问题。提前致谢。

4 个解决方案

#1


20  

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. 检查是否已将System.Data.SqlServerCe命名空间添加到应用程序的References文件夹中。如果不存在,您可以右键单击References文件夹并选择Add references选项。从弹出窗口转到.Net选项卡,从列表中选择System.Data.SqlServerCe,然后单击OK将命名空间添加到项目中。
  3. 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.
  4. 如果您对步骤1没问题,请使用System.Data.SqlServerCe添加;到使用System.Data.SqlServerCe命名空间的文件后面的代码顶部。

#2


5  

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

如果你有一个对System.Data.SqlServerCe的现有引用,但你看到旁边有一个黄色符号,那么你应该:

  • 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.

要重新添加:右键单击“引用”文件夹,然后选择“添加引用...”选项。转到装配体|左窗格中的Framework选项,然后在右窗格中滚动到System.Data.SqlServerCe。如果它在那里,请单击它,然后确保在单击“确定”之前选中它旁边的复选框。

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:

如果System.Data.SqlServerCe不在列表中,那么您将不得不在计算机上浏览它。为此,请单击“添加引用...”对话框的“浏览...”按钮,然后尝试查找此文件夹:

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.)

(上述示例中的v#。#值在您阅读本文时可能会有所不同,因此首先导航到C:\ Program Files \ Microsoft SQL Server Compact edition \然后选择最新版本或特定版本,如果您知道什么应该是。)

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

一旦通过浏览找到它,选择System.Data.SqlServerCe.dll文件并确定您的出路,然后尝试重新编译。

#3


3  

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

安装SQL Compact Server,然后直接从Microsoft Compact DataBase / Program文件夹添加崇敬system.data.SqlServerCe.dll。

You're missing the dll.

你错过了这个dll。

Im sure you already figured this one out though.

我相信你已经想到了这个。

#4


1  

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

检查您的web.config文件以获取对该文件的任何引用,并进行更正。它可能是您定义错误的别名。

This answer might solve your issue.

这个答案可能会解决您的问题。

#1


20  

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. 检查是否已将System.Data.SqlServerCe命名空间添加到应用程序的References文件夹中。如果不存在,您可以右键单击References文件夹并选择Add references选项。从弹出窗口转到.Net选项卡,从列表中选择System.Data.SqlServerCe,然后单击OK将命名空间添加到项目中。
  3. 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.
  4. 如果您对步骤1没问题,请使用System.Data.SqlServerCe添加;到使用System.Data.SqlServerCe命名空间的文件后面的代码顶部。

#2


5  

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

如果你有一个对System.Data.SqlServerCe的现有引用,但你看到旁边有一个黄色符号,那么你应该:

  • 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.

要重新添加:右键单击“引用”文件夹,然后选择“添加引用...”选项。转到装配体|左窗格中的Framework选项,然后在右窗格中滚动到System.Data.SqlServerCe。如果它在那里,请单击它,然后确保在单击“确定”之前选中它旁边的复选框。

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:

如果System.Data.SqlServerCe不在列表中,那么您将不得不在计算机上浏览它。为此,请单击“添加引用...”对话框的“浏览...”按钮,然后尝试查找此文件夹:

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.)

(上述示例中的v#。#值在您阅读本文时可能会有所不同,因此首先导航到C:\ Program Files \ Microsoft SQL Server Compact edition \然后选择最新版本或特定版本,如果您知道什么应该是。)

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

一旦通过浏览找到它,选择System.Data.SqlServerCe.dll文件并确定您的出路,然后尝试重新编译。

#3


3  

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

安装SQL Compact Server,然后直接从Microsoft Compact DataBase / Program文件夹添加崇敬system.data.SqlServerCe.dll。

You're missing the dll.

你错过了这个dll。

Im sure you already figured this one out though.

我相信你已经想到了这个。

#4


1  

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

检查您的web.config文件以获取对该文件的任何引用,并进行更正。它可能是您定义错误的别名。

This answer might solve your issue.

这个答案可能会解决您的问题。