我利用openqq进行数据同步,在用户A修改行H之后,其他好友用户重新加载行H。代码就不贴了。问题是,我为了验证列“用户单位”,不能空和不能重名,在Datacolchanging事件中写入了以下代码:
If e.DataCol.Name = "单位名称" Then
If e.NewValue Is Nothing Then
MessageBox.show("单位名称不能空着","提示",MessageBoxButtons.OK,MessageBoxIcon.Error)
e.Cancel = True
Else
Dim h As DataRow
h = e.DataTable.sqlfind("单位名称 = '" & e.NewValue & "'")
If h IsNot Nothing Then
MessageBox.show("单位名称已经存在")
e.Cancel = True
End If
End If
End If
运行时提醒“名称已存在”。我想是该代码标黄的部分会导致load该行时造成的。
但我是分页的设计,所以用SQLFIND。请问这能解决吗?