How to avoid duplicate data?

Discussion of open issues, suggestions and bugs regarding Virtual Data Access Components for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

How to avoid duplicate data?

Post by 99Percent » Mon 20 Sep 2010 22:17

How can avoid duplicate fields in a virtual table? There is no keyfields property and lookup and locate don't work while editing a record.

AndreyZ

Post by AndreyZ » Thu 23 Sep 2010 10:52

Hello,

I could not reproduce the problem.
Please send me a complete small sample to andreyz*devart*com to demonstrate the problem.

99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Post by 99Percent » Fri 24 Sep 2010 19:12

Let me explain a bit more.

Supose you want to add a row with a field that requires unique values. How do you check that the field does not contain data that is already in the dataset?

For example you have a table T with Field F, you want to be sure Field F does not have a value already present in the table T before adding the row to the table. How do you check? If you are editing the row and call Locate, a scroll event occurs that forces the record to be posted, and VirtualTable does not have a Keyfields property that will disallow the row to be inserted with the duplicate value.

AndreyZ

Post by AndreyZ » Tue 28 Sep 2010 08:38

The TVirtualTable component doesn't support such functionality. But you can write the code that checks TVirtualTable for duplicate records using the AfterPost event and the Locate method.

Post Reply