Visual Studio 数据集设计器刷新表

发布于 2024-08-29 07:20:43 字数 293 浏览 14 评论 0原文

在 Visual Studio 数据源设计器中,有没有办法在保留自定义查询的同时刷新表及其关系/外键约束?

我目前的做法是删除表格并再次添加。这将添加所有关系并刷新所有字段。

另外,如果我更改字段数据类型,是否有办法自动刷新数据源中的所有字段?再次无需删除表并再次添加。

原因是因为我的一些 TableAdapter 附加了相当多的复杂查询,当我删除表时,适配器也会被删除,包括其所有查询。

我正在使用 Visual Studio 2008 并连接到 MySQL 数据库。

大家有什么想法吗?

In visual studio datasource designer is there any way to refresh a table and its relations/foreign key constraints while keeping the custom queries?

The way I am doing it at the moment is removing the table and adding it again. This adds all the relations and refreshes all fields.

Also if I change a fields data type, is there a way to automatically refresh all the fields in the datasource? Again without deleting the table and adding it again.

Reason for this is because some of my TableAdapters have quite a number of complex queries attached to them and when I remove the table the adapter gets removed as well including all its queries.

I am using Visual Studio 2008 and connecting to a MySQL database.

Any1 have an idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

吃不饱 2024-09-05 07:20:43

每个表都有一个默认查询(顶部带有检查的查询)。当您将表拖入数据集以创建查询时,它会编写一条 SQL 语句,用于架构您的表。保持该查询简单,您可能实际上不会在代码中使用它,并且您始终可以编辑该查询以更新表架构。

每次您打开默认查询时,它都会连接到您的数据源,并允许您选择以前不存在的新列。如果要更新现有列,请在尝试打开查询之前从表中删除所有列。当您保存查询时,更新的列将被添加回来。

确保您的连接字符串有权查看列信息。

Each table has a default query (The one on top with the check on it). When you dragged your tables in to the dataset to create the query, it wrote a SQL statement which it uses to schema your table. Keep that query simple, you might not actually use it in code, and you can always edit that query to update the table schema.

Every time you open the default query it connects to your datasource and allows you to select new columns that weren't in there before. If you want to update your existing columns, delete all the columns out of the table before you attempt to open the query. When you save the query, your updated columns get added back.

Make sure your connection string has permissions to view column information.

扛刀软妹 2024-09-05 07:20:43

我向 MSFT 报告了此事,但​​没有得到回应。设计者始终关注最简单的 SQL 语句。我发现对我有用的是。

  1. 向设计器添加一个新表。
  2. 保存起来。
  3. 关闭 Visual Studio 2010。
  4. 启动 VS 2010。
  5. 再添加一两个 SQL 语句,然后再次执行步骤 2-4。

这是一个令人头疼的问题,但也是阻止 Visual Studio 数据集设计器挂起的唯一方法。我在 VS 2008 中也遇到过同样的问题。我正在连接到 Oracle,但仍然关闭 VS 并重新启动它,但实际上,这是无稽之谈。

I reported this to MSFT but no response. The designer hangs all the time on the simplest of SQL statements. What I found that works for me is.

  1. Add a new table to the designer.
  2. Save it.
  3. Shut down visual studio 2010.
  4. Start VS 2010.
  5. Add one or two more SQL statements and follow steps 2-4 again.

This is a pain in the neck but the only thing that stops Visual Studio dataset designer from hanging. I experienced in this same issue in VS 2008. I am connecting to Oracle but still shutting down VS and starting it back up works, but really, this is nonsense.

時窥 2024-09-05 07:20:43

您可以添加/更改/删除字段和关系,但我建议查看 NHibernate。

You can add/change/remove fields and relation ships, but i would suggest looking into NHibernate.

陌路终见情 2024-09-05 07:20:43

您应该能够右键单击解决方案资源管理器中的数据集,然后选择“运行自定义工具”来刷新表及其查询/关系。

如果该命令不存在,请检查数据集属性的“自定义工具”字段中是否有“MSDataSetGenerator”。

You should be able to right-click the dataset in solution explorer and select "Run Custom Tool" to refresh the table and it's query/relationships.

If that command is not there, check that the dataset properties has "MSDataSetGenerator" in the Custom Tool field.

吝吻 2024-09-05 07:20:43
  1. 右键单击您的数据集名称,然后选择数据集属性。
  2. 在查询框下方,您将看到刷新字段按钮。
  3. 单击“查询设计器”,新字段应显示在表列表中。
  1. Right click on your DataSet name and select Dataset Properties
  2. Below the Query box you will see a button for Refresh Fields.
  3. Click on Query Designer and the new field should show in your table list.
稍尽春風 2024-09-05 07:20:43

从 Visual Studio 解决方案资源管理器中右键单击 .xsd 文件

进入 .xsd 文件的属性

将“构建操作”设置为“内容”

将“自定义工具”属性更新为“MSDataSetGenerator”。您需要将其写入提供的文本框中。

输入图片此处描述

Right Click the .xsd file from Visual Studio Solution Explorer

Go into the .xsd file’s Properties

Set the "Build Action" to "Content"

Update the "Custom Tool" property to "MSDataSetGenerator". You need to write it in the Text Box Provided.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文