【问题标题】:The type name 'DatasetTableAdapters' does not exist in the type类型中不存在类型名称“DatasetTableAdapters”
【发布时间】:2013-08-05 08:59:03
【问题描述】:

我在TabControl 中添加了一个DataGridView 控件,以显示存储在名为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'

我的项目名称是'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();

(我在 MSDN 论坛上发现了一个类似的主题,虽然我无法通过阅读解决我的问题。Read it here.

【问题讨论】:

  • 我想您的解决方案也称为 WineCellar?所以你有一个...\WineCellar\WineCellar\WineCellar 文件夹?
  • 在我的项目文件夹中,它的结构为...\Projects\Winecellar\Winecellar
  • 那么解决方案文件夹是哪一个?
  • 子文件夹(第二个)。
  • 请仔细记录您的文件夹结构和命名空间。这是相关部分,我们现在必须猜测。

标签: c# datagridview dataset tableadapter


【解决方案1】:

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

短期修复:

 //this.cellarDataSet = new Winecellar.CellarDataSet();
   this.cellarDataSet = new Winecellar.Winecellar.CellarDataSet();

【讨论】:

  • 这个结果是The type name 'Winecellar' does not exist in the type 'Winecellar.Winecellar'
  • 是的,我猜你的文件夹和命名空间的能力到此结束。
  • 我修改了项目属性并将命名空间重命名为更明确的名称和推理。这样做,错误变得更加明显,易于解决。以后,我会更仔细地命名我的应用程序结构。谢谢!
  • 或者您可以删除命名空间...this.cellarDataSet = new CellarDataSet(); 解决问题的任何一种方式。谢谢!!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-03-31
  • 1970-01-01
  • 2020-03-05
  • 2010-12-04
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
相关资源
最近更新 更多