Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Invalid Column Name SQL error after renaming table field name

Posted on 2008-10-21
3
Medium Priority
?
879 Views
Last Modified: 2012-05-07
I am working in an ASP.Net project that I inherited.  I was doing some cleanup and found some table column names that were misspelled.  I wanted to rename the columns so that future searches would find all instances of this name.  So, I renamed the field in SQL using Enterprise Manager, then going to Design Table and then renaming the field.  Then, I updated all the code with the references to the column.

Now, when I am running debug testing, I get to the ExecuteNonQuery command (I am updating the table), I get the 'SqlException was caught' error.  The errors list 'Invalid column name 'oldname'.

There must be something cached somewhere but I'm not sure how to correct this.

We are running Visual Studio 2005, SQL2000.
Thanks for any help.
0
Comment
Question by:smodesitt
3 Comments
 
LVL 7

Expert Comment

by:the_bachelor
ID: 22771540
Or simply the columname in the SQL statement doesn't match the one in the Database.
Triple Check..
0
 
LVL 2

Expert Comment

by:johnhumenik
ID: 22772160
Are you using a stored procedure or class layer to hit the database?  I would do a search on the whole project and make sure that you got all instances of the variable name updated.  If notthing else, post the code and table layout for review.  
0
 

Accepted Solution

by:
smodesitt earned 0 total points
ID: 22777487
I finally figured it out myself.  For some reason, when I renamed the field (didn't matter whether I did it in Enterprise Manager or using DBCC command in Query Analyzer), the Constraints and Triggers were not updated.  I finally updated those areas using Query Analyzer and all is good.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview
Suggested Courses

916 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