Link to home
Start Free TrialLog in
Avatar of Dalexan
DalexanFlag for Afghanistan

asked on

BC30002: Type 'dataset' is not defined.

I've searched the Net over and have not found true love.  My app was running on our server, then I added a dataset class...now all I get is this BC30002 error on all my dataset classes in the app.
I tried the varied solutions I found all to no avail.  Most reference vs 2003 and 2005...I am running with VS 2008 using VB asp.net
One thing I found that I cannot explain is in the project's obj\debug\HARM.xml file...all the member names have T: or M: or F: prepended to the class name.  Don't know if this is relevant.
I get this when trying to run the app on our server and when trying to run it within VS2008.
Can anyone point me to something...please??
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

I think that you will need to show more detail on the error that you are getting.  Are you trying to reference the System.Data.DataSet class, and inside of your project you have a DataSet class of your own?
Avatar of Dalexan

ASKER

I created a dataset by right-clicking the project and selecting Add/New Item.  The object and code generated are shown in the image I have attached.  The T: M: and F: I referred to can be seen in the attached xml file.  The error I get is:

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'dsCAMPAIGN_SCRIPT_VIEW' is not defined.

Source Error:

Line 11:     End Sub
Line 12:
Line 13:     Public Function GetData(ByVal filter As String) As dsCAMPAIGN_SCRIPT_VIEW
Line 14:         bc = New bcSqlServer(mySession)
Line 15:         Return bc.GetDs(filter, New dsCAMPAIGN_SCRIPT_VIEW)

Source File: C:\projects\HMRAM\HarpARM\App_Code\Agent_Apps\BC\bcCAMPAIGN_SCRIPT_VIEW.vb    Line: 13

HarpARM.PNG
HARM.xml
If you created the typed DataSet, the proxy code generator will assign it a namespace.  If the namespace is not the same as the default project namespace, then you will need an Imports statement at the top of the code module for the typed DataSet's namespace.
Avatar of Dalexan

ASKER

I don't see any namespace assignments...as you can see, the bc and ds files are both directly under the project namespace 'HARM'; although the bc file was not when I first checked...I had to remove it, add it under the project, save it, then move it to the subfolder where it now resides (the same folder it was in as shown in my earlier post).  I've had an issue with classes not registering properly in the past...mostly with the ds classes.  This has been more prevalent in 2008 and usually not a problem in 2005.
HarpARM2.PNG
I was confusing the DataSet for the table adapter.  If you look at that image, you can see that the table adapters are listed in the class view under the namespaces, like dsACCESS_CODES.  

What kind of database working with?
Avatar of Dalexan

ASKER

We are accessing a MS SQL Server 2000 database.
Since you have SQL Server databases, have you looked at the LINQ-to-SQL DataContexts?  There is a significant improvement over the table adapters.
Avatar of Dalexan

ASKER

No, I haven't...this is a project I'm porting to another environment that was developed 3 years ago.  Not being familiar with the LINQ stuff, I haven't even looked.  Would it be a significant change to convert?
Well, that depends on different factors:

1) How the project is designed, and if you are using wrapper classes that hide the data access layer implementations.  

2) Your level of experience with LINQ

3) Your ability to learn new things.

4) Available development time

If none of these are enticing enough, then another approach that I would suggest--recreate the typed DataSets in 2008, since migration is not always perfect.
Avatar of Dalexan

ASKER

Time is probably the worst constraint...we wrapped everything down to the database in classes, so actual db access is constrained to a small area.  What I know of LINQ is minimal but I can learn.

Oh, yes, and I already did delete all the ds's and recreated them from scratch in 2008...along with the bc classes...didn't help.
Can you show me some of the code generated for the problem typed DataSet designer file?  

Example:


'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:2.0.50727.4927
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On



'''<summary>
'''Represents a strongly typed in-memory cache of data.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"),  _
 Global.System.Serializable(),  _
 Global.System.ComponentModel.DesignerCategoryAttribute("code"),  _
 Global.System.ComponentModel.ToolboxItem(true),  _
 Global.System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema"),  _
 Global.System.Xml.Serialization.XmlRootAttribute("AdventureWorksDataSet"),  _
 Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")>  _
Partial Public Class AdventureWorksDataSet
    Inherits Global.System.Data.DataSet

Open in new window

Avatar of Dalexan

ASKER

Here's the designer file for the dataset...
dsCAMPAIGN-SCRIPT-VIEW.Designer.vb
Hmmm...that looks just fine.  What type of web site are you working with (Web Site model = no project file, or Web Application model = project file)?  For the Web Site model, data classes should be in the App_Code folder.
Avatar of Dalexan

ASKER

I think the correct answer is Web Application...just a master page, web.config, and all the other pages and classes in the project folder.
I believe that the correct answer, if there is no .vbproj file, is Web Site model, which means that the DataSet files need to be in the App_Code folder.  When you add a new DataSet, and that folder doesn't exist, then the IDE asks if you would like to add that folder, and then it places the DataSet files in the App_Code folder.
Avatar of Dalexan

ASKER

hmmm, well, I do have a HARM.vbproj file...it's attached...
HARM.vbproj
Everything looks good, and there is nothing that explains your problem.  Can you create a new test web application, create a typed DataSet, and have it work correctly?
Avatar of Dalexan

ASKER

I apologize for the delay...my job includes current maintenance, customer support, and development of future apps.  Unfortunately, future apps gets the back seat.
I created a new app and added a dataset to it with no problems...including populating a dropdown list.
I've been spending a lot of time on this...first it works (I had 9 datasets in the app and it was working), then I add a dataset, and everything fails.
I think I'm at the point where I need to start from scratch and upgrade the design to use LINQ, etc.  Do you have any get-up-and-running-quick references I might use?
LINQ is a pretty large subject to cover, and I have used a lot of references to get where I am today, but I don't have a specific quick start reference in mind.

Let's come up with one:

1) Add a data layer class library project to your solution

2) A LINQ-to-SQL file to the data layer project (Add New Item | LINQ to SQL Classes).

3) Drag and drop tables from the Server Explorer, with a connection defined to the SQL Server database, to the DataContext designer surface.  Relationships between tables will automatically create associations for the tables on the DataContext designer.

4) Drop stored procedures on the right-hand pane, to create methods that will execute the stored procedures.

5) Add a class to the project that will create an instance of the DataContext

6) Add methods to the DataContext class to get the data that you need.

7) There are plenty of resources to learn how to create LINQ statements the duplicate the SQL Server queries.  Most are language specific, so you would need to find VB.NET examples.

    A good search expression is your best friend (i.e. VB.NET LINQ examples)

    101 LINQ Examples
    http://msdn.microsoft.com/en-us/vbasic/bb688088.aspx


Public Class DataLayer

    Private m_dataContext As AdventureWorksDataContext = Nothing

    Public Sub New(ByVal connectionString As String)

        If String.IsNullOrEmpty(connectionString) Then
            m_dataContext = New AdventureWorksDataContext()
        Else
            m_dataContext = New AdventureWorksDataContext(connectionString)
        End If

    End Sub

    Public Function GetProductList() As List(Of Product)

        Dim query = From product In m_dataContext.Products _
                    Order By product.Name _
                    Select product

        Return query.ToList()
    End Function

End Class

Open in new window

Screenshot.png
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dalexan

ASKER

Beautiful.  It looks so simple and elegant.
If anyone else is dealing with this type of problem, LINQ may be the real solution.
Since VS2008 still has bugs in dealing with ds's and can't seem to get it's head on straight with it all, porting this old code is a waste of time; and I wasted a LOT of time fighting with this.
LINQ, by your description and example, and by the examples your link pointed to, I'm convinced that's the way to go. (hopefully, it doesn't have the same kind of 'bugs')
THANK YOU!