SQL Error checking

Only with Debug mode of course.