I would like to add a way to see if an entry is already in a connected database in the following code and if it is, not to add the entry and pop up a dialog saying something to the effect of "already been scanned" and if it is not to proceed as usual. a simple if statement should do.
Using connection As New SqlClient.SqlConnection("Data Source=XXXXX;Initial Catalog=XXXXXX;Integrated Security=True;Pooling=False;Encrypt=False"), _
cmd As New SqlClient.SqlCommand("INSERT INTO [XXXXX] (TrackingNumber, Date) SELECT @TrackingNumber, @Date WHERE NOT EXISTS (SELECT * FROM([XXXXX])WHERE TrackingNumber = @TrackingNumber AND Date = @Date)", connection)
cmd.Parameters.Add("@TrackingNumber", SqlDbType.VarChar, 50).Value = TrNum
cmd.Parameters.Add("@Date", SqlDbType.DateTime, 8).Value = TrDate
connection.Open()
cmd.ExecuteNonQuery()
connection.Close()
End Using