Mauricio
Error handling through SQL or C#.
@becquerel I started thinking about this a couple days ago while building a feature for a school project. The idea was simple. I have a table of employees, a table of course assignments (shows what courses an employee teaches) and a course enrolment table (shows what courses a student has been enrolled to, this table contains information like course grade and which teacher set the grade etc etc). In the course enrolment table I wanted to make sure that only teachers that has been assigned to that particular course can set the grades for it. I solved the problem by creating a trigger that checks if the grade setter ID in the enrolment table matches the ID in the course assignment table. It works fine. The reason I choose to do it this way is because I felt like it would be extra steps to first get the data from the database, do the check through C# and then update the table if everything is correct.
10 replies