I've written an SQL select statement. I've checked te statement in SQL Server Management Studio Express and it works greate. When I go take the code to my asp page and insert it, I get a generic IIS 500 error. When I take out my variable I'm tyring to use, it works just fine. I've written the response out and it shows the correct data. Here is my code.

<%
    CurrentYear = Year(Date)
    UserID = Request.QueryString("id")

    sqlCOURSES = "SELECT syl.id AS sid, d.dept AS department, syl.course_name AS cname, syl.classroom_number AS room, syl.course_number AS cnumber, syl.section_number AS snumber, syl.semester_year yr, sem.semester AS semester, syl.class_DaysTimes AS dt, l.Name building FROM tbl_Syllabus AS syl LEFT OUTER JOIN tbl_departments AS d ON syl.dept_ID = d.ID LEFT OUTER JOIN tbl_semester AS sem ON syl.semester = sem.ID LEFT OUTER JOIN tbl_locations AS l ON syl.building = l.id WHERE syl.people_ID = '" + UserID + "' AND syl.semester_year = " + CurrentYear + " ORDER BY sem.sort ASC"

%>

If I take the CurrentYear out of the code above and replace it with the year manually it works fine. When I put this code in, it displays the year just fine.

<%
    CurrentYear = Year(Date)

    response.write(CurrentYear)
%>

You are missing the single quotes...

AND syl.semester_year = '" + CurrentYear + "' ORDER BY sem.sort ASC"

I added the single quotes and still getting the same error.

hmmm. im not seeing it at this moment by looking at your code. If in your query you manually have AND syl.semester_year = '2014' ORDER BY sem.sort ASC", its OK, then... ?

Yes, if I manually put in '2014' it works just fine.

Using +'s instead of &'s is what was causing my issue. I've got it working fine now. Thanks for the help.

Aw missed that completely! VBScript and VB.NET uses & for concatenation.