I have a customer file in MS ACCESS, it contains many tables.
Case:
In table(X) for Column(Y) there is validation rule of “=1 Or 2”. I want to change it to “=1 OR 2 OR 3 OR 4” if Possible, Its an Byte column. Otherwsie i want to completly remove the validation rule for that column. I am using C# and i need a query to do so…….
Access SQL can not be used to add, remove, or alter a Validation Rule. That can only be done through the DAO TableDef.
If you were using VBA in Access, you could do this to create your Validation Rule.
I used
IN (1,2,3,4)instead of1 OR 2 OR 3 OR 4, but either should work.Perhaps you can use
Microsoft.Office.Interop.Accessto do the same from c#.An alternative would be to create a check constraint with Access SQL. A check constraint is not the same as a Validation Rule, but could be used to accomplish the same goal.
You would still need to discard the existing Validation Rule. If that’s not feasible, you could create a new table with the same structure as the old, add the check constraint, and finally load data from the old to the new table.