检查datagridview中是否已经存在一个值 [英] Check if a value already exist in a datagridview

查看:124
本文介绍了检查datagridview中是否已经存在一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人可以帮我吗?

我正在从标签向datagridview添加值.但是在插入值之前,我想检查该值是否在datagridview中不存在.我在堆需要帮助.

在此先感谢您.

Hi,

Can somebody help me out?

I am adding values to a datagridview from a label. But before i insert the value, i want to check if the value does not already exist in the datagridview. I am stack. Need help.

Thanks in advance.

推荐答案

您可以对使用datagridview进行分配的Assign数据集进行查询.例如.
You can make query on assign dataset which is assign with datagridview. for example.
dim ds as new dataset
Dim da as new oledb.OledbDataAdapter("Select * from table1",conn)
da.Fill(ds)

DataGridView1.DataSource = ds.Table(0)

''Now if you want to check that record is all ready exists of not.
dim dr as datarow()
dr = ds.Table(0).select("SearchFieldName = " & ''SearchValue)
if dr.Length >0 then 
   Messagebox.show("Duplicate Record")
end if


这篇关于检查datagridview中是否已经存在一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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