如何将数据从datatable更新为sql表? [英] How to update data from datatable to sql table?
本文介绍了如何将数据从datatable更新为sql表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个sql表与
ID(unique) Name status
1 A 0
2 B 0
在我的代码中,我将所有数据检索到数据表中并进行一些编码。
根据结果,我将结果从0更改为1或2
In my code, I retrieve all data into a data table and do some coding. Based on the results, I will change the results from 0 to 1 or 2
之后,我需要将其更新回到sql。
After that, I need to update them back to sql.
我的想法是创建一个临时表,将每行插入到..然后将其更新为真正的sql表,删除临时表。
My idea is to create a temp table, insert every row into that .. and then update them to the real sql table, delete the temp table.
不是很好,我知道。这就是为什么我问,有没有更好的方法呢?
Not very good, I know. That's why I am asking, is there any better way to do that?
推荐答案
你可以更新表的内容使用 CommandBuilder 。
You can update the content of the table back working with a CommandBuilder .
查看此示例。
这篇关于如何将数据从datatable更新为sql表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文