How to create a constraint with multiple columns using OLEdb

Pat Hanks 141 Reputation points
2023-01-02T21:45:21.62+00:00

The use case is for an Access database using OLEdb via C#. I need to build the tables or alter afterward to establish the relationships between a couple tables. I am able to get the relationship with one column in the table to another column in a foreign table. I am using this syntax for the constraint, CONSTRAINT FK_indexname REFERENCES tablename (columnName) ON DELETE CASCADE. However I need to have a single column (ID) to multiple columns in a foreign table. The use is I have a item table for all the items used and a recipe table where several columns will reference the item table. Here is what I built in Access that I need to understand the proper syntax to use in my code.

275450-relationship.gif

Thanks for your help

Microsoft 365 and Office | Access | Development
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.