以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]SQLtable表中做重复值检查  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=108229)

--  作者:cyh2017
--  发布时间:2017/10/18 16:56:00
--  [求助]SQLtable表中做重复值检查
用控件按钮“保存”时,检查新增“用户名”在SQLtable表中“用户名”列中是否已存在,如果存在,则清除改行。

下面这段代码要怎么改呢?

If
 e.DataCol.Name = "订单号" Then
    Dim
 dr As DataRow 
    dr = e.
DataTable.Find("订单号 = \'" & e.NewValue & "\'")
    
If dr IsNot Nothing Then
        MessageBox.Show(
"此订单号已经存在!")
        e.Cancel = 
True
    End
 If
End
 
If
--  作者:有点甜
--  发布时间:2017/10/18 18:17:00
--  
Dim t As Table = Tables("表A")
For i As Integer = t.rows.count-1 To 0 Step -1
    Dim r As Row = t.rows(i)
    Dim idx As Integer = t.FindRow("第一列 = \'" & r("第一列") & "\' and _Identify <> " & r("_Identify"))
    If idx >= 0 Then
        r.delete
    End If
Next
t.save