The type name 'DatasetTableAdapters' does not exist in the type

a 夏天 提交于 2019-12-11 09:30:01

问题


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.

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'

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.

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?

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();

(I found a similar topic on the MSDN-forum, though I could not resolve my problem from reading it. Read it here.


回答1:


You are confusing the code generator with the double namespace. Best thing to do is rename the subfolder and the associated namespace.

Short fix:

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


来源:https://stackoverflow.com/questions/18044850/the-type-name-datasettableadapters-does-not-exist-in-the-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!