Reputation: 3
In a VS2012 Project I like to set a records datafield (DateTimeStamp) to the current system datetime if the corresponding rowstate is added or modified. To do so I use the code as followes:
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
In the DEBUG steps I recognize that the Date is transfered to the datacolumn but after the update and requering the record the column contains not data.
Any Idea why?
Upvotes: 0
Views: 131