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)
%>