我无法更新我的bindingnavigator [英] I cannot update my bindingnavigator

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

问题描述

您好,

亲爱的会员,当我尝试删除并更新我的bindingnavigator时,它会向我显示以下错误。

更新在传递DataRow集合时需要有效的DeleteCommand已删除的行。

我不会发生错误以下是更新我的绑定导航器的代码

  .Validate()
.TableAdapterManager.UpdateAll( .myDataSet)
.myBindingSource.EndEdit()



Plz我需要你的帮助.. 。

解决方案

您没有提到删除命令。在适配器对象的属性中,检查删除命令字段。

如果此表没有主键,则无法删除或更新。


尝试检查TableAdapterManager更新的属性&删除命令以查看它们是否有效。



如果受影响的表没有主键,这也可能导致此类问题。



参考 [ ^ ]


尝试放置EndEdit线在您进行更新之前。



如果这不起作用,您可以尝试旧方法。我从未见过这种失败。我在UpdateAll(Me.myDataSet)之后使用它来检查它是否真的更新了。

这是无关紧要的,应该是不必要的,但它确实有效。

只需更改数据集名称和TableAdapter名称。您甚至可能希望将它们放入Try Catch

  If  yourDataSet.HasChanges 然后 
' 不要忘记自DataRow以来的'()'是一个数组
dim drModified() as DataRow = yourDataSet.Table。 选择 ,_
DatViewRowState.ModifiedCurrent)
如果 drModified.Count> 0 然后
yourTableAdapter.Update(drModified) ' 不是TableAdapterManager
结束 如果

Dim drDeleted() As DataRow = yourDataSet。表。选择 ,< span class =code-string> ,_
DataViewRowState.Deleted)
如果 drDeleted.Count> 0 然后
。 yourTableAdapter.Update(drDeleted)
结束 IF

Dim drAdded() As DataRow = yourDataSet.Table。 Select < span class =code-string>,_
DataViewRowState.Added)
如果 drAdded.Count> 0 然后
yourTableAdapter.Update(drAdded)
结束 如果
结束 如果

' 您还可以将上述内容合并为一行如下所示。
Dim drModified() As DataRow = yourDataSet.Table。 选择 ,_
DataViewRowState.ModifiedCurrent DataViewRowState.Added)

' 我会将Deleted行分开,以便您确认所有如果需要,删除和取消。


Hello,
Dear memebers, when I'm trying to delete and update my bindingnavigator it shows me following error.
Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.
I dont whats going wrong following is the code to update my binding navigator

Me.Validate()
Me.TableAdapterManager.UpdateAll(Me.myDataSet)
Me.myBindingSource.EndEdit()


Plz i need ur help...

解决方案

You have not mentioned your delete command. In the properties of the adapter object check the delete command field.
If there is no primary key for this table then you can not delete or update.


Try checking the properties of the TableAdapterManager update & delete commands to see if they are valid.

If the table being affected has no primary key this can also cause this type of problem.

Reference[^]


Try putting your EndEdit line before you do the update.

If that doesn't work, you can try the old method. I've never seen this fail. I use it after the UpdateAll(Me.myDataSet) to check if it really updated.
It's extraneous, and should be unnecessary, but it works.
Just change the Dataset names and TableAdapter names. You might even want to put them in a Try Catch

If yourDataSet.HasChanges then
  'Don't forget the '()' since DataRow is an array
  dim drModified() as DataRow = yourDataSet.Table.Select("", "", _ 
      DatViewRowState.ModifiedCurrent)
  If drModified.Count > 0 then
     yourTableAdapter.Update(drModified)     'Not TableAdapterManager
  End If

  Dim drDeleted() As DataRow = yourDataSet.Table.Select("", "", _
      DataViewRowState.Deleted)
  If drDeleted.Count > 0 Then
     Me.yourTableAdapter.Update(drDeleted)
  End IF

  Dim drAdded() As DataRow = yourDataSet.Table.Select("", "", _
      DataViewRowState.Added)
  If drAdded.Count > 0 Then
      yourTableAdapter.Update(drAdded)
  End If
End If

'You can also combine the above into one line as below.
Dim drModified() As DataRow = yourDataSet.Table.Select("", "", _
     DataViewRowState.ModifiedCurrent Or DataViewRowState.Added)

'I would keep the Deleted line separate so you can confirm all deletes and cancel if you want.


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

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