Solved

Invalid column name error

Posted on 2003-10-24
3
304 Views
Last Modified: 2010-05-19
I am having a problem with an error message.
When I try to drag the last name field from the table under Cottages(this is the name of the database on SQL Server from MSDE it was taken from a student files disk), I get an error message:
 
Data Adapter Configuration Error
 
The wizard detected the following problems when configuring the data adapter for "Guests".
Details:
 Generated SELECT statement
 
Invalid column name 'Last'
 
I can cancel or click OK
When I click OK, I get the Connection and Data Adapter Components in the component tray.  I can name them.
But when I try to generate the dataset, I get another error message.
 
Microsoft Development Environment
 
Retrieving the schema for daLastName failed
 
Invalid column name 'Last'
 
I can click cancel or OK
 
When I click OK I get the Generate Dataset box
I can name the dataset, but there are no tables to choose from in the box below
I am in the design view of the guests( I will be adding textboxes and a combo box to display info from the database) form. The guests form is a child form
What am I doing wrong
Thanks, Kay
0
Comment
Question by:wait3264
  • 2
3 Comments
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 170 total points
Comment Utility
The problem is that "last" is a reserved word for SQL Server / MSDE.  

The easiest fix is to rename the table "last name" to "last_name" or "LastName".  This way the table name won't be parsed into two pieces.

Note however that this will break any triggers or stored procedures that referenced this table so they'll need to be fixed (there probably aren't any though because they would likely have already choked on the 'last').
0
 
LVL 4

Accepted Solution

by:
NetPointer earned 80 total points
Comment Utility
this will also work.
[last name]
0
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 170 total points
Comment Utility
NetPointer,

The brackets will work if you're writing the code by hand but it sounds like Kay is using Visual Studio and dragging the table.  This means the IDE is throwing an error right away.  

Of course you can still edit the sql manually but why bother with drag-n-drop if you're going to that?

Frodoman
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now