Click here to Skip to main content
16,010,297 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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
 
Share this answer
 
Comments
Kofi Ambrose 29-Jun-10 7:41am    
Thanks dhaval. But the issue is, i want to compare the text on a label to the values in the datagridview to see if the datagridview contains the text on the label already or not. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900