PDA

View Full Version : Validate against two columns in a database to prevent data insertion


Travis250923
03-26-2009, 09:59 AM
I am trying to do a multiple item insert so that I can add a product to multiple categories. I have is setup using checkboxes and hidden fields to insert the needed information. Is there a way to get the insert behavior to check the database against two values in the table?

Essentially this table combines the ItemCatID from my categories table and my ItemID from the items table to have a one-to-many relationship between items and categories (I think this is the best way to do it). I want DA to check and make sure the combination of ItemCatID and ItemID do not already exist to prevent a duplicate insertion. Any thoughts on this?

Thanks

Ray Borduin
03-26-2009, 01:05 PM
You could do it with validation toolkit... basically create a recordset that filters by those values and then use validation toolkit to validate that the number of results is zero.

Or just write the code to check it and redirect to prevent insert if you are familiar with php and don't own validation toolkit.

Travis250923
03-26-2009, 01:28 PM
I just found and used the manage relational table function in data assist and it seems to do what I want and not insert a combination of records more than once.