Solved

Invalid column name error

Posted on 2003-10-24
3
305 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
ID: 9616244
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
ID: 9616292
this will also work.
[last name]
0
 
LVL 42

Assisted Solution

by:frodoman
frodoman earned 170 total points
ID: 9616685
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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