Click here to Skip to main content
16,015,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am connecting a ms-access database to my c#.net application.

Connection is successfull then i'hv generated dataset named dataset1 its also done, but after that when i am trying to open design view of that form, i get following error.

1.Could not find type 'DataSet1'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.

2.The variable 'dataSet11' is either undeclared or was never assigned.


I am also posting some part of my auto generated code of .designer


System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form2));
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.dataSet11 = new FTServerCode.DataSet1();//this line creates problem
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.textBox3 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.SuspendLayout();
//
// oleDbSelectCommand1


Thank you in advance
Posted
Updated 10-May-11 19:54pm
v2
Comments
Ankit Rajput 11-May-11 2:15am    
Can you please provide the code?

you say you created Dataset1 and have a missing reference to dataset11 (*eleven) that is a typo I believe.
 
Share this answer
 
What you need to do is add the datasource to the project, then drag the autogenerated dataset onto the form from the Data source explorer. Sounds like you are adding the dataset from the toolbox. if you are trying to write the code yourself, do so and do not mix and match with auto generated unless you know how to correct the code mess that will happen.
 
Share this answer
 
v2
Comments
sunitadit11 11-May-11 2:53am    
can please explain this in some more detali
because when i auto generate dataset from oledbadpters property window it comes on form automatically

also tellme where is the data source explorer

and i am not adding it from toolbox and i've not modified the code in .designer at all
When you add a datasource to a project you get a datsource explorer window in VS 2005 / 2008 /2010 ?
Also where is the oleDBadapter coming from ? is it auto-generated. The dataAdapter is normally generated from the strongly typed xsd dataset, which is generated from the database.
This all occurs from the drag and drop procedure normally. These auto generated items are then added to the toolbox, if you then drag and drop them again an incremental denominator is added to give them instance names.
ie customerTableadapter1
customerTableadapter2
etc.
What are you trying to do ?
 
Share this answer
 
Comments
sunitadit11 11-May-11 8:31am    
i have taken the oleDBadapter from toolbox and dragged it on form then all the connection process i've done successfully
then from the property window of oledbadapter which contains 3 tags at the end i've clicked on "generate dataset" up to here every thing is fine but after that when i double click on forms designer view it gives me following 2 errors
1.Could not find type 'DataSet1'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.

2.The variable 'dataSet11' is either undeclared or was never assigned.


same way i've made a test application it is working fine but in the original application it gives me error :(

if you want i can post the entier .designer file code


thanks for your response :) expecting a solution from you.
sunitadit11 11-May-11 8:37am    
i am not understanding why it gives error if i've already genrated a dataset named dataset1

i found only this line is looking different in the auto generated code
this.dataSet11 = new FTServerCode.DataSet1();

FTServerCode is my namespace an also there is a class named FTServerCode inside it
is it the problem

do you know how to reference an aasembly?

because error says "Please make sure that the assembly that contains this type is referenced."
C#
FTServerCode is my namespace an also there is a class named FTServerCode inside it
is it the problem.



Change the class name, see what happens
 
Share this answer
 
Comments
fjdiewornncalwe 11-May-11 9:24am    
Could you please in the future use the "Improve Solution" link and update your existing answer when that is what you are doing. Creating new answers for each addition simply makes the thread very difficult to read.
About "do you know how to reference an assembly?"

Whenever we provide any object or type name in our code whose class, namespace or assembly is not defined by us, system shows object reference error.

So, be sure that you have declared assembly or reference to all declared objects.

Since you've told that your class and namespace name are same:

- First of all change name of your class. Let its be "FTVClass"
- On top while declaring assembly references also add reference to namespace as below:
using FTVSetverCode;




Also try with changing your following errored line of code :
"this.dataSet11 = new FTServerCode.DataSet1();//this line creates problem"

with

FTVClass Fclass = new FTVClass();

DataSet DataSet11;
DataSet11 = new DataSet();
DataSet11 = FTVClass.DataSet1();
 
Share this answer
 
v3
I would also read the following

http://oreilly.com/catalog/9780596004392[^]

This will certainly help you.
 
Share this answer
 
I agree with Mini Mouse - it looks like a typo. Try the code below:

MIDL
this.dataSet1 = new FTServerCode.DataSet();//this line creates problem


Alternatively, if using Visual Studio, right click on this.dataSet1 and select Go To Definition. That should take you to the code where dataSet11 is declared. Change the declaration to be FTServerCode.DataSet1 dataSet11 = default(FTServerCode.DataSet1);.

Finally, is DataSet1 a class defined in the namespace FTServerCode, or is FTServerCode the class and DataSet1 a static method? If that's the case, you'll need to ensure that dataSet11 is of the same type (or a super class / interface) as the return type of that method.

Hope that's of some help?

Cheers,

JB

ps. FYI: try to avoid using having class and namespace names the same - more info here:
[^]
 
Share this answer
 
v2
Thank you..minnie mouse,sk saini,JohnLBevan for your great response

the main problem is name of "namespace" and "class" is same when i changed the class name dataset is working fine once again thank you all for your grate support


if any other problem occurs now i'am sure that you guys will help me :) thank youuuuu...

-Sunit
 
Share this answer
 
Try with changing the name of your class "FTServerCode". The same name of your namespace and class may cause this error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900