Solved

Invalid column name error

Posted on 2003-10-24
3
307 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 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