Hi, i am trying to write a code to Insert new records, and while doing so, want to check if the ID already exist. Finding it difficult to code. here's my code.
Dim ic As Integer
ic = Val(Me.TextBox1.Text) ' ic for ItemCode
Dim foundRow As DataRow = ds.Tables("ITEM").Rows.Find(ic)
If foundRow IsNot Nothing Then
'MsgBox(foundRow(1))
MsgBox("Duplicate Value. Please enter a new ID")
Exit Sub
End If
frmEdit_Items.ITEMTableAdapter.Insert(Me.TextBox1.Text, Me.TextBox2.Text, Me.TextBox3.Text)
frmEdit_Items.ITEMTableAdapter.Fill(frmEdit_Items.KSDBDataSet.ITEM)
frmEdit_Items.ITEMTableAdapter.Update(frmEdit_Items.KSDBDataSet.ITEM)