无法使用新列更新表适配器上的查询
我正在开发一个带有一些强类型 SQL 表适配器的项目,我对此一点也不熟悉。我通过设计器添加了一个新列,但以前存在的查询(基本获取)不会看到新列。经过一番折腾后,我终于通过执行以下操作“看到”查询生成器中的新列:
1)右键单击查询,选择“配置”
2)点击“上一个”按钮,直到系统提示我选择我的数据库连接字符串。
我必须将其更改为开发数据库,其中包含新列
3) 使用“下一步”按钮继续执行向导,而不进行任何其他更改。
应该注意的是,即使我已经通过设计器手动添加了该列,这些步骤也是必需的。
一旦我这样做了,附加到设计器中的表的查询就可以很好地“看到”新列。我们将这个更新后的表称为 FirstTable。
但是,我对来自另一个表的另一个预先存在的查询存在问题,该表与 FirstTable 进行了联接。我将另一个表称为 SecondTable。
我右键单击 SecondTable,选择“配置”,然后在向导中单击“上一个”,这样我就可以选择正确的连接字符串。完成了向导,大概是使用这个新的连接字符串重新设计了 SecondTable(该表没有实际更改)。
但是,将 SecondTable 连接到 FirstTable 的查询无法看到 FirstTable 中的新列。
我的最后一次尝试是删除这两个表之间映射的“关系”,然后重新创建它。我认为这将允许 SecondTable 看到 FirstTable 中的新列,以便可以在联接中使用它。
目前,无论我是否直接修改 SELECT 语句,还是使用查询生成器(查询生成器根本看不到新列,并且不允许我添加它),我都会收到“无效的列名”错误手动)。我确实完全限定了表名称(例如dbo.TableName.ColumnName),
几个小时以来我一直在努力解决这个问题。有人有什么建议吗?
编辑:我在查询生成器中重新添加了 FirstTable,以查看它是否会刷新可用的列数据。不走运 - 它仍然停留在旧的列名称上。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然不明白上述问题的根源是什么,但我找到了解决方法。在我的更新中,我提到在查询构建器中删除并重新添加联接表不会更新列名称。但是,如果我创建了一个全新的新查询,然后在查询生成器中添加了连接表...然后噗,新列就在那里。如果有人知道更好的方法来做到这一点,我仍然洗耳恭听(这需要根据前一个查询创建一个新查询,将其命名为一个重复名称,删除旧名称,将新名称重命名回原始名称......真是一团糟)。
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).