在VS2012项目中,如果添加或修改相应的行状态,我喜欢将记录数据字段(DateTimeStamp)设置为当前系统日期时间。为此,我使用以下代码:
Private Sub LicenceCheckBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles LicenceCheckBindingNavigatorSaveItem.Click
Me.Validate()
Dim dt As DataTable = EfaDesktopDataSet.Tables("LicenceCheck").GetChanges
If Not IsNothing(dt) Then
For Each dr As DataRow In dt.Rows
If dr.RowState <> DataRowState.Unchanged And dr.RowState <> DataRowState.Deleted Then
dr.BeginEdit()
dr.Item("DateTimeStamp") = Date.Now
dr.EndEdit()
End If
Next
Else
Dim dr As DataRow = LicenceCheckBindingSource.Current.row
If dr.RowState = DataRowState.Unchanged Then
If isDataChanged(dr, "RuleTitle") Then
End If
End If
End If
Me.LicenceCheckBindingSource.EndEdit()
Me.LicenceCheckTableAdapter.Update(Me.EfaDesktopDataSet.LicenceCheck)
End Sub
在DEBUG步骤中,我认识到Date已转移到数据列,但在更新并重新请求记录之后,该列不包含数据。
任何想法为什么?
答案 0 :(得分:1)
尝试在AcceptChanges
后的DataTable
上致电loop
。