问题
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