类型中不存在类型名称"DatasetTableAdapters"

Dan*_*l B 1 c# datagridview dataset tableadapter

我已经向我添加了一个DataGridView控件来TabControl显示存储在本地应用程序数据库的单个表中的数据Cellar.sdf.

当我将数据源添加到DataGridView时,我选择要显示数据的表并预览数据.它显示数据库中的内容.

当我构建项目时,我收到以下错误:

The type name 'CellarDataSetTableAdapters' does not exist in the type 'Winecellar.Winecellar'
The type name 'CellarDataSet' does not exist in the type 'Winecellar.Winecellar'
Run Code Online (Sandbox Code Playgroud)

我的项目名称是'Winecellar'.当我在VS2012中创建项目时,它创建了一个子文件夹,导致文件结构'Winecellar.Winecellar',但我不确定这是否与此问题有关.在文件夹里面我确实有文件,CellarDataSet它说我失踪了.

我是否TableAdapter必须为我的数据库创建一个单独的数据库,或者我必须以不同的顺序执行操作才能使其工作?

导致我的错误的代码行在我的Form1.Designer.cs文件中,

(1)        this.cellarDataSet = new Winecellar.CellarDataSet();
           this.wineBindingSource = new System.Windows.Forms.BindingSource(this.components);
(2)        this.wineTableAdapter = new Winecellar.CellarDataSetTableAdapters.WineTableAdapter();
Run Code Online (Sandbox Code Playgroud)

(我在MSDN论坛上发现了一个类似的主题,虽然我无法通过阅读它来解决我的问题.请在此处阅读.

Hen*_*man 5

您将代码生成器与双命名空间混淆.最好的办法是重命名子文件夹和关联的命名空间.

简短修复:

 //this.cellarDataSet = new Winecellar.CellarDataSet();
   this.cellarDataSet = new Winecellar.Winecellar.CellarDataSet();
Run Code Online (Sandbox Code Playgroud)