例如B用户加载了
"表A"的一条数据,而A用户在B用户加载之后删除了该条数据
目前B用户的Datatable中还存在这条数据,B用户可以通过代码 tables("表A").Current()修改数据,经过认真测试,执行代码tables("表A").Current.save()保存该表时,如果数据库中没有该条数据,则Table中会自动删除该数据,但是没有提示,我的解决方式是BeforeSaveDataRow事件中加入下面代码:
If e.DataRow.RowState = DataRowState.Added OrElse e.DataRow.RowState = DataRowState.Detached Then
Else
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Select count(*) from {STAllocate} where _identify = " & e.DataRow("_identify")
Dim s As Integer = cmd.ExecuteScalar
If s <1 Then
e.Cancel = True
MessageBox.Show("该数据已被删除,保存无效")
End If
End If
以上方法比较麻烦,望各位高手赐教。
[此贴子已经被作者于2013-10-4 10:18:09编辑过]