使用datagrid更新数据库 [英] Update database using datagrid

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

问题描述

谁能给我一个例子,说明如何使用datagrid将其更改反映到您的mysql数据库中....

我已尝试执行以下操作.

创建DataGridView(我让.NET创建BindingSource的东西)
在我的保存"按钮单击事件中输入了以下代码,但这给了我一个错误
(在传递带有已修改行的DataRow集合时,Update需要有效的UpdateCommand.)

Can anyone give me an example how to use datagrid that will reflect its changes to your mysql database....

i have tried doing the following.

Create the DataGridView (I let .NET create the BindingSource stuff)
Entered the following code into my ''Save'' button click event,but it gave me an error
(Update requires a valid UpdateCommand when passed DataRow collection with modified rows.)

Me.Validate()
Me.StgCustomerBindingSource.EndEdit()        
Me.Stg_CustomerTableAdapter.Update(Me.AdventureWorksDataSet.Tables("stg_Customer"))



please.your答复将是非常有用的帮助.



please.your reply will be be a very big help

推荐答案

指定数据适配器的更新命令,因为看来datagrid并未填充数据中的所有数据桌子.因此,它需要知道确切的update命令来保存数据.这是可以帮助您的链接:

http://msdn.microsoft.com/en-us/library/33y2221y.aspx [ ^ ]
Specify the update command for data adapter as it seems the datagrid is not populated with all the data from the data table. Therefore it needs to know the exact updatecommand to save the data. Here is the link which can help you:

http://msdn.microsoft.com/en-us/library/33y2221y.aspx[^]


从中下载演示项目.

http://www.codeproject.com/KB/database/DataGridView2Db.aspx
download the demo project from.

http://www.codeproject.com/KB/database/DataGridView2Db.aspx


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

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