Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends,

i want to compare a single row of one table with multiple rows of other table and if that single row is present in other table's rows then it should give a message that record already existed.

i want to achieve this in vb and i dont have any idea how to accomplish this anyone has any sample code of how to do this in vb.

please needed help
Posted
Comments
Mahesh Bailwal 24-Aug-13 8:21am    
are you talking about database table or ADO.Net datatable?
sachin bhise 25-Aug-13 2:23am    
mahesh m talking about ado.net datatable

1 solution

Try this:
For Each dr As DataRow In FirstDataTable.Rows

	Dim results As System.Data.EnumerableRowCollection(Of System.Data.DataRow) = From myRow In SecondDataTable.AsEnumerable() Where (myRow.Field(Of String)("Id").Trim() = dr("Id").ToString().Trim())myRow

	If results.ToList().Count <> 0 Then


		MessageBox.Show("Row Exist")

	End If
Next
 
Share this answer
 
v4

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