本文介绍了如何在GridView中跟踪重复数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre lang="vb">Dim connection As OleDbConnection<br />
 connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " _<br />
& "Data Source=" & Server.MapPath("~/Database/dbLupon.mdb") & ";")<br />
 Dim commandPos As OleDbCommand<br />
 commandPos = New OleDbCommand("Select POSITION_C FROM tblLupon_C WHERE POSITION = ''C'' REGION_C = ''" & lblRegion_C.Text & "'' AND PROVINCE_C = ''" & lblProvince_C.Text & "'' AND CITYMUN_C = ''" & cmbCityMun.SelectedValue & "'' AND BARANGAY_C = ''" & cmbBarangay.SelectedValue & "''")<br />
 connection.Open()<br />
 Dim DataReader As OleDbDataReader<br />
 DataReader = commandPos.ExecuteReader()<br />
 If GridView1.Rows.Count = 0 Then<br />
     MsgBox("AKO!")<br />
 Else<br />
     While DataReader.Read<br />
         MsgBox("duPLICATE")<br />
     End While<br />
 End If</pre><br />



大家好!
我在重复数据方面遇到问题.
我的代码对吗?我的记录中必须有一位主席.



hello guys!
I''m having a problem regarding duplicate data.
Is my code right? I must have one Chairman in my record. thanks!

推荐答案


If Not DataReader.HasRows Then
    MsgBox("AKO!")
Else
    While DataReader.Read
        MsgBox("duPLICATE")
    End While
End If




如果有帮助,请将其标记为答案.




Mark it as answer if it is helpful.


这篇关于如何在GridView中跟踪重复数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:31