Carlos kambui

Carlos kambui

  • NA
  • 499
  • 126.8k

check if value already exist

Apr 10 2017 8:21 AM
i have a table stock with column stock_id,stock_code stock_desceription etc
stock_id is the primary key while i have stock_code is indexes/key i want stock_code to be unique i every row,am able to do so and also am able to check whether stock_code exist before i insert,now my question is how can i be able to check for dublicate before i update,
below are my code that check before i insert
tStock = svcClient.GetLocationStocksByScanCode(MainConn, cbolocation.SelectedValue, TxtScancode.Text).FirstOrDefault
If Not IsNothing(tStock) Then
MessageBox.Show("Item already exist in the location!", "Softbit Tech")
Return
End If
 now what can i do to check before i update 

Answers (5)