VS2008数据集向导不匹配表更新 [英] VS2008 DataSet Wizard doesn't match tables for updating

查看:503
本文介绍了VS2008数据集向导不匹配表更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次上这个网站的问题。

first question ever on this site.

我一直在使用Visual Studio 2008中有一个真正的顽固的问题,我希望有人之前已经想通了这一点。

I've been having a real stubborn problem using Visual Studio 2008 and I'm hoping someone has figured this out before.

我有2个图书馆和1个项目使用强类型数据集(MSSQL后端),我生成使用在数据源中的配置数据集与向导选项。我有他们的工作就好了一段时间,我在该行类的非设计文件写了很多code。我也指定了不少使用DataSet设计器自定义查询。这是所有的工作我不能松动。

I have 2 libraries and 1 project that use strongly typed datasets (MSSQL backend) that I generated using the "Configure DataSet with Wizard" option on in Data Sources. I've had them working just fine for awhile and I've written a lot of code in the non-designer file for the row classes. I've also specified a lot of custom queries using the dataset designer. This is all work I can't afford to loose.

我最近做了一些改动,重新组织我的图书馆,其中包括改变库本身的名称。我也改变了连接字符串指向不同的数据库,这是一个发展的复印件(完全相同的模式)。

I've recently made some changes to re-organize my libraries which included changing the names of the libraries themselves. I also changed the connection string to point to a different database which is a development copy (same exact schema).

但问题是现在,当我打开配置数据集与向导皮卡新的专栏中,我已经添加到其中一个表不再表正确向导匹配。该向导将显示所有数据库中的表和他们都没有旁的复选框他们(即:不是这个数据集的一部分)。低于它显示了所有的表,但再次用红色两个X和这些被检查。基本上,这意味着Visual Studio中看到的一切目前在DataSet中的表,看到所有的表在数据库中,但他认为他们不再是相同的,因此不匹配!

Problem is now when I open up "Configure DataSet with Wizard" to pickup a new column I've added to one of the tables it no longer matches the tables correctly in the wizard. The wizard displays all of the tables in the database and none of them have check boxes next to them (ie: are not part of this dataset). Below those it shows all of the tables again but with red Xs and these are checked. Basically meaning that Visual Studio sees all of the tables it currently has in the DataSet and sees all of the tables in the database, but believes they are no longer the same and thus do not match!

我有同样的事情发生的很长一段时间回来,我想我只是重新建从无到有的XSD和手动复制code以上,然后不得不重新定义所有的自定义查询我建的数据集设计师。这不是一个很好的解决方案。

I've had this same thing happen quite awhile back and I think I just re-built the xsd from scratch and manually copied the code over and then had to redefine all of the custom queries I built in the dataset designer. That's not a good solution.

我在寻找2答案: 1.是什么原因导致这种情况发生,以及如何prevent它。 2.我该如何解决这个问题,以便向导再次认为,表中的XSD是在数据库中(是的,他们有相同的名字仍然)相同的表。

I'm looking for 2 answers: 1. What causes this to happen and how to prevent it. 2. How do I fix this so that the wizard once again believes the tables in its xsd are the same tables that are in the database (yes, they have the exact same names still).

感谢。

推荐答案

该数据集设计使用默认查询(第一个上有一个检查)同步为每个表的模式。每当你去修改默认的查询,VS实际上会连接到您的数据源和寻找变化中的查询。如果新列的添加,他们将显示为新列,为您添加到您的表。重命名列显示为新的,因为VS没有任何办法知道你改了名字。

The dataset designer uses the default query (The first one with a check on it) to sync up the schema for each table. Whenever you go to edit the default query, VS will actually connect to your datasource and look for changes in the query. If new columns are added, they will show up as new columns for you to add to your table. Renamed columns show up as new, since VS doesn't have any way to know that you changed the name.

答1. XSD文件包含它原先用于创建表的数据库表的名称。如果更改了表的名称,设计人员不知道同步到哪个表。

Answer 1. The XSD file contains the names of the database tables that it used to create the table originally. If you change the name of the table, the designer won't know which table to sync to.

答2.您可以编辑XSD文件中的XML。做一个查找和替换XSD文件替换旧表名的新表名内。请确保您有XSD文件的备份,在此之前。小心只有改变旧的表名和实例没有任何其他工作的XML。

Answer 2. You can edit the XML inside the XSD file. Do a "Find and Replace" inside the XSD file replacing the old tablename for the new tablename. Make sure you have a backup of the XSD file before you do. Be careful to only change instances of the old table name and not any other working XML.

这篇关于VS2008数据集向导不匹配表更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆