[英]Button code to save data on datagridview
I am trying to use this code on vb2010 datagrid to save changes made on the datagrid but the problem is that even when the user clicks save button and they didnt make any changes, the MsgBox("Changes Successfully Effected.") is stil displaying that changes are made.我正在尝试在 vb2010 数据网格上使用此代码来保存对数据网格所做的更改,但问题是即使用户单击保存按钮而他们没有进行任何更改,MsgBox("更改已成功生效。") 仍然显示进行了更改。
Me.Validate() Me.StudentsBindingSource.EndEdit() Me.TableAdapterManager1.UpdateAll(Me.DataSet) MsgBox("Changes Successfully Effected.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
How will i fix this? Me.Validate() Me.StudentsBindingSource.EndEdit() Me.TableAdapterManager1.UpdateAll(Me.DataSet) MsgBox("Changes Successfully Effected.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
我将如何解决这个问题?
Put your code in an if condition like below.将您的代码置于如下 if 条件中。
IF Me.DataSet.HasChanges() Then
Me.TableAdapterManager1.UpdateAll(Me.DataSet)
MsgBox("Changes Successfully Effected.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.