简体   繁体   中英

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. Me.Validate() Me.StudentsBindingSource.EndEdit() Me.TableAdapterManager1.UpdateAll(Me.DataSet) MsgBox("Changes Successfully Effected.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly) How will i fix this?

Put your code in an if condition like below.

IF Me.DataSet.HasChanges() Then
  Me.TableAdapterManager1.UpdateAll(Me.DataSet)
  MsgBox("Changes Successfully Effected.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM