自动保存DataGridView行到SQL Server数据库得到错误 [英] Auto Saving DataGridView Rows to a SQL Server Database got error

查看:97
本文介绍了自动保存DataGridView行到SQL Server数据库得到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iam写作

自动保存DataGridView行到SQL Server数据库 [ ^ ]我在ado.net表单中编写此代码,但它在sda.Update上给出了错误(lastdatarow);这行是''System.Data.Common.DbDataAdapter.Update(System.Data.DataRow [])''的最佳重载方法匹配,有一些无效的参数,无法从''System.Data.DataRow''转换为''System.Data.DataRow []''我怎么能解决这个问题实际上我在一个datagridview中绑定两个表

iam writing
Auto Saving DataGridView Rows to a SQL Server Database[^] ia writing this code in my ado.net form but it give me error on sda.Update(lastdatarow); this line that is The best overloaded method match for ''System.Data.Common.DbDataAdapter.Update(System.Data.DataRow[])'' has some invalid arguments and cannot convert from ''System.Data.DataRow'' to ''System.Data.DataRow[]'' how can i solve this actually im binding two tables in one datagridview

推荐答案

因为你的错误说你试图通过只有一行,但你调用的那个方法

System.Data.Common.DbDataAdapter.Update正在接受数据行数组作为其参数值。所以首先尝试传递数据行的行。然后尝试逐行调试你的代码并找出是否存在任何其他问题。



如果你只想更新一行然后创建只有一行的数组元件。或者您想要更新多行,然后在该数据行数组中添加要更新的行,并将其传递给您的方法。
As your error says your are trying to pass only one row, but that method you called
"System.Data.Common.DbDataAdapter.Update" is accepting data row array as its parameter value. so first of all try to pass array of data row. then try to debug your code line by line and find out any other issue is there or not.

if you want to update only one row then create array with only one element. or you want to update multiple row then add as much row as you want to update in that data row array and pass it to your method.


这篇关于自动保存DataGridView行到SQL Server数据库得到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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