问题描述
我已经将 DataGridView
控件添加到我的 TabControl
中,以显示存储在单个表格中的数据一个本地应用程序数据库,名为 Cellar.sdf
。
I've added a DataGridView
control to my TabControl
to display data that is stored in a single table of a local application database called Cellar.sdf
.
当我将数据源添加到DataGridView时,我选择表我想显示数据并预览数据。它显示数据库内的内容。
When I add the data source to the DataGridView, I select the table I want to display data from and preview the data. It displays the content inside the database.
当我构建项目时,我收到以下错误:
When I build the project I get the following errors:
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
它说我失踪了。
My project name is 'Winecellar'
. When I created the project in VS2012, it created a subfolder resulting in the file structure 'Winecellar.Winecellar'
, though I am not sure if this has something to do with this problem. Inside of the folder I indeed have the file CellarDataSet
it says I am missing.
我必须创建一个为我的数据库分开 TableAdapter
,或者我必须以不同的顺序执行操作才能使其工作吗?
Do I have to create a separate TableAdapter
for my database, or must I do things in a different order to get this to work?
导致我的错误的代码行在我的Form1.Designer.cs文件中,
The code lines that are causing my errors is in my Form1.Designer.cs file,
(1) this.cellarDataSet = new Winecellar.CellarDataSet();
this.wineBindingSource = new System.Windows.Forms.BindingSource(this.components);
(2) this.wineTableAdapter = new Winecellar.CellarDataSetTableAdapters.WineTableAdapter();
(我在MSDN论坛上发现了一个类似的主题,尽管我无法从阅读中解决我的问题它。
(I found a similar topic on the MSDN-forum, though I could not resolve my problem from reading it. Read it here.
推荐答案
你是将代码生成器与双重命名空间混淆,最好的做法是重命名子文件夹和相关的命名空间。
You are confusing the code generator with the double namespace. Best thing to do is rename the subfolder and the associated namespace.
简化修复:
//this.cellarDataSet = new Winecellar.CellarDataSet();
this.cellarDataSet = new Winecellar.Winecellar.CellarDataSet();
这篇关于类型名称“DatasetTableAdapters”不存在于类型中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!