检查记录副本的代码 [英] code of check the record duplicate

查看:38
本文介绍了检查记录副本的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我已编程此代码,我确定在贴上之前记录是否重复虽然他确实告诉我,如果记录是重复的,但是他保存了记录......

我想帮我把下面的代码保存在记录重复的情况下





Hi

I have programmed this code for i sure that record a duplicate or not before affixed Although he actually told me in the case that the record is a duplicate , but he saved the record...
I'd like to help me make the code below does not save in the case the record duplicate


Try

            For i As Integer = 0 To Ds.Tables("OrderForm").Rows.Count - 1
                If CustTextBox.Text = Ds.Tables("OrderForm").Rows(i).Item("Cust").ToString Then
                    MsgBox("Order added Before !", MsgBoxStyle.Information)
                    Exit Try
                End If
            Next


            Dim R As DataRow = Ds.Tables("OrderForm").NewRow
            R(0) = OrderNoTextBox.Text
            R(1) = CustTextBox.Text
            R(2) = CustNoTextBox.Text
            R(3) = FactoryTextBox.Text
            R(4) = QtyTextBox.Text
            R(5) = RaiseOnTextBox.Text
            Ds.Tables("OrderForm").Rows.Add(R)
            Cmdb = New OleDbCommandBuilder(Da)
            Me.BindingContext(Ds, "OrderForm").EndCurrentEdit()
            Ds.AcceptChanges()
            Da.Update(Dt)

            MsgBox("Order added successfully !", MsgBoxStyle.Information)

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

推荐答案

试试这个



Try this

If Ds.Tables("OrderForm").AsEnumerable().Count(Function(row) row.Field(Of String)("Cust").Tolower() = CustTextBox.Text.toLower()) > 0 Then
 MsgBox("Order added Before !", MsgBoxStyle.Information)
	Return
End If


这篇关于检查记录副本的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆