表中有一列 卷号 ,由8个字符组成,例如
CS150001,其中150001部分必须是唯一值,比如不允许出现
CR150001,
在DataColChanged事件中写了以下代码,但显然是错误的,请老师修改一下:
If e.DataCol.Name = "卷号" Then
Dim dr As DataRow
dr = e.DataTable.SQLFind("[卷号].Contains(" & e.NewValue.SubString(2,6) & ")'And [_Identify] <> " & e.DataRow("_Identify") )
If dr IsNot Nothing Then
MessageBox.Show("所录入的卷号已经存在并且保存于后台,请检查后继续操作!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.DataRow("卷号") = e.OldValue
End If
End If