C#datagridview保存按钮单击时在行中所做的更改 [英] C# datagridview save changes made in rows on button click

查看:61
本文介绍了C#datagridview保存按钮单击时在行中所做的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我需要帮助(当然):)

如何保存按钮单击后在datagridview行中所做的更改

我有
tabledatadapter daData
数据集dsData
绑定源DataBS

此代码

Hello

I need help (of course) :)

how to save changes made in datagridview rows on button click

I have
tabledatadapter daData
dataset dsData
binding source DataBS

this code

daData.SelectCommand = new SqlCommand("SELECT * from DataDetails", cs);
dsData.Clear();
daData.Fill(dsData);

DataBS.DataSource = dsData.Tables[0];



并更新buttonclick



and for update on buttonclick

daData.Update(dsData);



但这给了我这个错误



but it gives me this error

Update requires a valid UpdateCommand when passed DataRow collection with modified rows.



想法想法想法



ideas ideas ideas

推荐答案



检查这些链接.

http://support.microsoft.com/kb/308507 [ SqlDataAdapter.UpdateCommand属性 [ http://stackoverflow.com/questions/8171647/c-sharp-using-dataadapter-to-update-sql-table-from-a-datatable-sql-table-no [ http://stackoverflow.com/questions/6833277/c- sharp-dataadapter-update-does-not-update-the-database [ http://stackoverflow.com/questions/6135215/dataadapter-update-command [ ^ ]

希望这会有所帮助.
Hi,

check these links.

http://support.microsoft.com/kb/308507[^]
SqlDataAdapter.UpdateCommand Property [^]
http://stackoverflow.com/questions/8171647/c-sharp-using-dataadapter-to-update-sql-table-from-a-datatable-sql-table-no[^]
http://stackoverflow.com/questions/6833277/c-sharp-dataadapter-update-does-not-update-the-database[^]
http://stackoverflow.com/questions/6135215/dataadapter-update-command[^]

hope this helps.


我希望会有所帮助:
I hope it helps:
daData.UpdateCommand = new SqlCommandBuilder( daData).GetUpdateCommand();



检查此

Hi ,
Check this

daData.Update(dsData);
        daData.AcceptChanges();


最好的问候
米特瓦里(M.Mitwalli)


Best Regards
M.Mitwalli


这篇关于C#datagridview保存按钮单击时在行中所做的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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