Matt
Matt

Reputation: 41832

Unable to update query on Table Adapter with new columns

I'm working on a project with some strongly typed SQL Table Adapters, which I am not at all familiar with. I added a new column via the designer, but the previously existing Query (basic fetch) would not see the new column. After much putzing around, I finally got it to "see" the new column in the query builder by doing:

1) Right click on query, select 'configure'

2) Hit the 'previous' button until I am prompted to select my database connection string.
I had to change it to the development database, which contained the new column

3) Continue through the wizard with the 'next' button, without making any other changes.

It should be noted that these steps were required even though I had already manually added the column via the designer.

Once I did this, the Query attached to the table in the designer could 'see' the new column just fine. We'll call this updated table FirstTable.

However, I am having a problem with another pre-existing query from another table which did a join with FirstTable. This other table I'll call SecondTable.

I right clicked on SecondTable, selected 'configure', and hit 'previous' in the wizard so I could select the proper connection string. Finished the wizard, which presumably redesigned SecondTable with this new connection string (there were no actual changes to this table).

However, the Query that joins SecondTable to FirstTable cannot see the new columns from FirstTable.

My last attempt was to delete the 'relationship' that had been mapped between these two tables, and recreate it. I thought that this would allow SecondTable to see the new columns in FirstTable so it could be used in the join.

Currently, I get 'invalid column name' error, regardless of whether or not I modifiy the SELECT statement directly, or use the Query Builder (the Query builder doesn't see the new column at all, and won't let me add it manually). And I did fully qualify the table name (e.g. dbo.TableName.ColumnName)

I've been banging my head against this for a few hours. Anyone have any tips?

EDIT: I re-added the FirstTable in the query builder to see if it would refresh the column data that is available. No luck - it is still stuck on old column names.

Upvotes: 0

Views: 1878

Answers (1)

Matt
Matt

Reputation: 41832

I still don't understand what the source of my problem above was, but I have found a work around. In my update I mentioned that removing and re-adding the joined table in the Query builder did not update the column names. However, if I created a brand new query, and then added the joined table in the query builder ... then poof, the new columns are there. If anyone knows of a better way to do this, I'm still all ears (this required creating a new Query based on the previous, naming it a dupe name, removing the old, renaming the new back to the original name... what a mess).

Upvotes: 1

Related Questions