从数据库更新数据表而不使用UPDATE语句? [英] Update database from datatable without using UPDATE statement?

查看:228
本文介绍了从数据库更新数据表而不使用UPDATE语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将自己的代码编写为以下代码:
将sql数据库中的表加载到dataTable1之后:

I have coded my own as the following:
After loading a table in the sql database into dataTable1:

textBox1.DataBindings.Add("Text", dataTable1, "Name");



编辑textBox1中的内容后,我检查了名称"列第一行中单元格的值,它已更改为textBox1的Text. (第一行,因为这是加载dataTable1之后的当前行).然后我开始更新:



After editing something in the textBox1, I checked the value of the cell at the first row of the column "Name", it had changed to the Text of textBox1. (the first row because that''s the current row after loading the dataTable1). Then I started updating:

sqlAdapter1.Update(dataTable1);



我认为应该可以,但是数据无法更新.如果我更改名称"列第一行的单元格值,例如



I think it should work, but the data can''t be updated. If I change the value of the cell at the first row of the column "Name" like as

dataTable1.Rows[0]["Name"] = "Chan doi VL"

,效果很好.

你能帮我吗?我真的不想使用UPDATE语句.
非常感谢!

, it works perfectly.

Could you please help me out? I really don''t want to use UPDATE statement.
Thank you so much!

推荐答案

如果在数据表上调用AcceptChanges会发生什么?您尝试过吗?
What happen if you invoke AcceptChanges on your data table? Did you try it?


不使用更新语句就无法做到这一点.
You can''t do it without using the update statement.


这篇关于从数据库更新数据表而不使用UPDATE语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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