Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

BC30002: Type 'Column' is not defined. Error when usign Linq to SQL class

Posted on 2010-08-13
15
Medium Priority
?
738 Views
Last Modified: 2012-05-10
Hi Experts

I am getting this error when running a page with a gridview bound to a LinqDataSource that is using a Linq to SQL class as its data context.

The error is pointing to the line below in the designer.vb file

Line 907:      <Column(Storage:="_Management_System_ID", DbType:="Int")>  _
Line 908:      Public Property Management_System_ID() As System.Nullable(Of Integer)

Any ideas?

Thanks

Stewart
0
Comment
Question by:digital_soul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33436463
The ColumnAttribute class is defined in the System.Data.Linq.Mapping namespace, which is in the System.Data.Linq assembly.  You need a reference to this assembly in your project.
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33436517
The auto genarated Class file where the error is occuring does include

Imports System.Data.Linq
Imports System.Data.Linq.Mapping
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33436870
That is an Imports statement, but you also need a reference in your project to the System.Data.Linq assembly.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:digital_soul
ID: 33437127
In Visual Studio I am selecting Add reference and then selecting System.Data.Linq but its still not working.

Should doing this create a reference in my Web.Config file?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33438355
Are you working with a web application or web site (project file or not)?
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33438433
Yes its a Project file
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33438466
If you have a project file, then it should be under the References node in the Solution Explorer.


Snapshot.png
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33439574
Hi

There is a reference to System.Data.Linq Under Project - Properties - references. See attached screengrab

Cheers



screengrab.png
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33440351
I would look again, in the file folder where your code is, and see if you have a .vbproj file.  It looks like you have a Web Site model (File | New Web Site), instead of a Web Application model (File | New | VB.NET | Web | Web Application).  I asked that question before because there are differences between how the two models behave with ASP.NET.

I see that you are referencing System.Data.Linq v. 3.5, but it is not coming from the Global Assembly Cache (GAC).  I have ASP.NET 4.0, and you can see the difference between the references in this image:


Snapshot.png
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33440651
Its an ASP.NET Web Application created via File - New project as its part of a multi-project solution. There is a vbproj file.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33442092
VB.NET projects are different than C# projects.  With C# projects, you will see a References node in the Solution Explorer tree.  If you have the correct reference, and the correct Imports System.Data.Linq statements, then you have a system that is getting confused.  When ASP.NET compiles a web page, it includes all the referenced DLLs in the \bin folder.  I can't think of a specific reason for this, off the top of my head.
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33444075
I appear to have solved it. For some reaosn Visual Studio wasn't adding

<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

to the Web.config file. Ive assed this reference now and the page compiles fine. Thanks for your help though.
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33444227
Actually the problem is only partially solved. I can now set up a LInqDataSource and bind it to a datagrid and compile this ok. I cant seem to access my DataContext Class programtically though. Is there a difference between how you would access this class in a Project as opposed to a website? usually in a website id just create the Linq to SQL class using the designer and instantly be able to reference it in code ala:

Dim myDataContext As LinqClassDataContext = New LinqClassDataContext ()

In my Project file though Visuaol Studio is not recognising my DataContext Class, despite the file having been automatically generated as usual.
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33444299
It seemed to be because I was placing my DataContext classes in an App_Code folder which is presumbaly not a recognised Project directory as it isnt an option from Add ASP.NET Folder. As soon as I created the class in the root I was able to access it from code.

Is there a reason why the App_Code folder wouldnt work in a project as it does in  a website?

Cheers
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 33444790
You said that you were working with a Web Application model web site, and the App_Code, App_Data folders are a construct for Web Site model web sites, so that it can find the code and data modules.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question