I am having problems with preventing duplicates based on two or more columns in a Sharepoint Foundation environment. My idea is to create an event handler in C# to intercept the creation of a item in a list an check if the combination of two columns exists in the list already and send an error if it exists.

So the basic idea is: in List A, a booking list, I have column A (Time) and column B (Date). When the item is going to be created I want to have an event handler that intercepts the creation and checks if Time+Date already exists in the List so a double booking can't occur.

How can I do this?