If
CourseID
is
Integer
field, then you need to modify the query like below excluding extra single quote.
SqlCommand cmdC = new SqlCommand("Select Count(*) from UCK_Scheduler..COURSE_REGISTRATION inner join UCK_Scheduler..STUDENT on COURSE_REGISTRATION.StudentID=STUDENT.StudentID where CourseID=" + DGVC.Rows[r].Cells[c].Value.ToString() + "", cc.con);
Please debug you code and see what is the value of the query at runtime. Then take the query to
SQL Management Studio and run it. You can see the errors, if any.