简体   繁体   English

在datagridview上保存数据的按钮代码

[英]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.

相关问题 如何在不使用按钮的情况下将数据从 datagridview 保存到 sql 数据库 - How to save data from datagridview to sql database without using a button 将datagridview保存回数据库的按钮 - Button to save datagridview back to database 将 DataGridView 数据保存到 Access 数据库 - Save a DataGridView data to Access database 用户单击按钮时如何将DataGridView的一行或多行中新添加的数据保存到SQL Server中 - How to save newly added data in a row or rows from DataGridView into SQL Server when the user clicks a button 如何在一个 excel 文件中保存到 datagridview 数据 - How to save to datagridview data in one excel file 将数据从datagridview silverlight保存到数据库 - save data from datagridview silverlight to database 当我尝试通过datagridview将数据从表保存到另一个表时 - When I try to save data from table to another by datagridview 如何在绑定到数据表的datagridview中保存更改的数据 - How to save changed data in datagridview which is bound to a datatable 从VB.net中的DataGridView将数据保存到文本文件 - Save data to text file from DataGridView in VB.net 带有保存对话框的 vb 网络中的 datagridview 数据导出到 excel - datagridview data export to excel in vb net with save dialog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM