TableAdapter.UpdateAll(Dataset) 正在更新表中的所有列

发布于 2025-01-05 08:34:50 字数 405 浏览 0 评论 0原文

C#、VS2010

创建了一个 Datagridviewer 并将数据库表拖/放到 Windows 窗体上。

创建了“更新 CommanTex”:

UPDATE       minerals

SET                Tritanium = @p0, Pyerite = @p1, Mexallon = @p2, Isogen = @p3, Nocxium =    

@p4, Zydrine = @p5, Megacyte = @p6, Morphite = @p7

当我通过 DataGridViewer 进行编辑并使用 VS2010 自动生成的保存按钮进行保存时,这似乎会更新数据库中的每个字段。

如何让 Datagridviewer 只更新已更改的字段?

C#, VS2010

Created a Datagridviewer and Drag/Dropped the Database table onto a windows form.

Created the "Update CommanTex":

UPDATE       minerals

SET                Tritanium = @p0, Pyerite = @p1, Mexallon = @p2, Isogen = @p3, Nocxium =    

@p4, Zydrine = @p5, Megacyte = @p6, Morphite = @p7

This seems to update every field in the database when I edit via the DataGridViewer and save using the save button auto-generated by VS2010.

How do I get the Datagridviewer to only update the fields that were changed?

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

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

发布评论

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

评论(1

被翻牌 2025-01-12 08:34:50

这就是 TableAdapterDataAdapter 的工作原理。他们总是会更新每一栏。

像实体框架这样的 ORM 将在运行时生成 SQL,因此可以决定只为已更改的列生成 SET 子句。

That's how TableAdapter and DataAdapter work. They will always update every column.

An ORM like Entity Framework will generate the SQL at runtime, so can decide to only generate SET clauses for columns which have changed.

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