如何在Vb.net中使用BindingSource更新数据库 [英] How to update database using BindingSource in Vb.net
本文介绍了如何在Vb.net中使用BindingSource更新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好所有访客
我在更新sql server 2005
中的数据时遇到问题.
我这样使用:
Hi all visitors
I have a problem with update my data in sql server 2005
.
I use like this:
dataadapter.update(bindingsource.datasource)
之后,将显示如下错误:
传递DataRow
集合时,更新需要有效的UpdateCommand
.
请帮帮我
最好的问候,
after than will display an error like this:
Update requires a valid UpdateCommand
when passed DataRow
collection.
Please help me
Best Regards,
推荐答案
当您收到确切的错误消息时,最容易解决问题.您只需要使用Google.
您的情况也是如此.查看链接- ^ ].
顺便说一句,错误消息在这里很容易解释.您尚未为BindingSource
定义UpdateCommand
.要针对数据库进行更新,需要更新查询,并且您需要指定一个这样的查询-bindingsource.UpdateCommand =此处更新查询";
希望对您有所帮助!
Solving a problem is easiest when you have exact error message. You just need to Google for it.
So is your case. See the link - Error - Update requires a valid UpdateCommand when passed DataRow collection[^].
BTW the error message here is pretty self explaining. You haven''t defined anUpdateCommand
for theBindingSource
. To update something against database, an update query is required and you will need to specify one like this - bindingsource.UpdateCommand = "Update Query here";
Hope this helps!
在那里看看,也许对您有帮助
[ ^ ]
take a look there it maybe help you
[^]
我有个建议.
请看一下这篇文章.
用于从DataBase和使用反射将DataTable保存到数据库中 [ http://converter.telerik.com/ [ ^ ]
将C#代码转换为VB.NET代码
I have a suggestion.
Please take a look at this article.
General purpose class to fill DataTable(s) from DataBase and to save DataTable(s) to DataBase using reflection[^]
Using this general purpose class you can fillDataTable
(s) from database and saveDataTable
(s) to database easily.
The sample code given in the article is in C#.
You can use the code converter at Telerik.com
http://converter.telerik.com/[^]
to convert the C# code to VB.NET code
这篇关于如何在Vb.net中使用BindingSource更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文