I allow user to add more than one record (let say order lineitems), then only press save button to in one batch.
I need to check for record uniqueness after new record added.
1. How to check uniquness before actually save to db?
2. If I loop thru the records to check for uniqueness, any impact if my "record pointer" moved?
Thank you
'-- Set the values loCommand.Parameters.Item("@MyPrimaryKey").Value = lnPK loCommand.Parameters.Item("@MyTestField").Value = MyTestValue '-- Return Results Return Me.ExecuteScalar(loCommand) > 0End Function
Then just call this in your business rules when checking (or whenever you need to):
Thank you for reply.
Your sample code is to check if any duplicate record already stored in DB.
How about still in memory? My form allow user to add multiple records then only save.
BTW, anything need to set for multi records update? I remember that is a property to set for multiple record update but I cant recall where exactly. I failed to get it back from doc.
Combine the local and the server values to get your final result. Be sure to always exclude the current record otherwise this will return an incorrect value.