Q:

Make it appear in Not-Submitted list

I want to retrieve back Student names and Student ID that don't exist in the Submission table, but exist in the Students table, and bind it into the GridView. For example Class A has 40 students, but only 38 students submitted the project. I want the 2 students who don't submit to appear in the GridView where the Teacher can view it
SELECT *
FROM Students
    LEFT JOIN dbo.Submission ON Students.Student_Id = Submission.Student_Id 
                                AND Students.Subject_Id = Submission.Subject_Id 
WHERE Students.Subject_Class='" + Session["Subject_Class"].ToString() + "' 
      AND Students.Subject_Id = '" + Session["Subject_Id"].ToString() + "' 
      AND  Submission.Proj_Sub = '" + Session["Proj_Sub"].ToString() + "' 
      And Submission.Student_Id IS NULL

When I use the above-mentioned statement, the GridView appears to be empty.

A:

You probably want something like this.
SELECT *
FROM Students
WHERE Students.Subject_Class='" + Session["Subject_Class"].ToString() + "' 
      AND Students.Subject_Id = '" + Session["Subject_Id"].ToString() + "' 
      AND NOT EXISTS (SELECT *
                      FROM Submissions
                      WHERE Submissions.Student_Id = Students.Student_Id
                            AND Submissions.Subject_Id = Students.Subject_Id
                            AND Submissions.Proj_Sub = '" + Session["Proj_Sub"].ToString() + "')

There are a number of approaches you could take, but this seems like the cleanest. Most importantly, though, you should place emphasis on moving away from your currently-SQL-injection prone approach. Please parameterize your queries.

