Can someone please help me with this?? I'm trying to check if a part already exists in the dataset. This will work if add a part say "6969"....then the next part I add is "6969"..that works fine...but if there is a part "6969"...then another "2002"....then I try and add "2002" again....it still adds it..and it shouldn't...so if anywhere in the dataset the part number is contained...dont add new record!!
Code:Dim drCurrent as New Datarow drCurrent = oldform9.mPartsNumber.NewRow() drCurrent("PAR_NUMBER") = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0) If oldform9.mPartsNumber.Rows.Count < 1 Then oldform9.mPartsNumber.Rows.Add(drCurrent) Else Dim thisItem As System.Data.DataRow For Each thisItem In oldform9.PartsNumberData.Tables(0).Rows If drCurrent("PAR_NUMBER") = oldform9.PartsNumberData.Tables(0).Rows.Item(0).Item(0).ToString() Then MsgBox("equal") Exit For Else MsgBox("not equal:") oldform9.mPartsNumber.Rows.Add(drCurrent) Exit For End If Next End If
Thanks for the help in advance!!




Reply With Quote