如何在GridView中跟踪重复数据 [英] how to trace duplicate data in a gridview

查看:82
本文介绍了如何在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!

推荐答案

由于您正在使用查询,因此最好在查询本身中跟踪重复数据.
不允许重复数据显示在gridview中.
Since you are using a query, it would be better to trace duplicate data in the query itself.
Dont allow duplicate data to be displayed in the gridview.


我看不到任何将结果绑定到GridView1的地方.

从上面的代码,我做了很少的修改.我希望这将有助于找到重复项.

I don''t see anywhere you are binding the result to the GridView1.

From the above code, I did few modification. I hope this would help to find the duplicates.

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中跟踪重复数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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