Error Summary HTTP Error 502.2 - Bad Gateway The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "C:/ruby/lib/ruby/site_ruby/1.8/DBD/ODBC/ODBC.rb:168:in `execute': 37000 (102) [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'. (DBI::DatabaseError)
from C:/ruby/lib/ruby/site_ruby/1.8/dbi.rb:480:in `execute'
--- generated code ---
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
print "<?xml-stylesheet type=\"text/xsl\" href=\"/transformations/ocs.xsl\"?>\n"
print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
print "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\" xmlns:clifton=\"www.cliftoncollegeuk.com/dtds/clifton\" xml:lang=\"en\" lang=\"en\">\n"
print "\t<head>\n"
print "\t\t<title>Clifton College - Old Cliftonian Society - Register - Thank you</title>\n"
print "\t\t<link rel=\"home\" href=\"/\"/>\n"
print "\t\t\n"
print "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheets/questionnaire.css\"/>\n"
print "\t</head>\n"
print "\t<body>\n"
print "\t\t\n"
print "\t\t<!-- Begin content -->\n"
print "\t\n"
print "\t\t<h1>College Register</h1>\n"
print "\t\n"
print "\t\t<p class=\"intro\">Thank you for submitting your details.</p>\n"
print "\t\t\n"
print "\t\t<p><em>The information you have submitted is shown below. If there are any errors, please <a href=\"mailto:CKnighton@clifton-college.avon.sch.uk?Subject=Clifton College Register\">let us know</a>.</em></p>\n"
print "\t\t\n"
print "\t\t";
require "dbi"
require "cgi"
class String
def escape_single_quotes
self.gsub(/[']/, '\'\'')
end
end
db = DBI.connect("DBI:ODBC:driver={SQL Server};Server=dmzapp3.cc.ent;Database=Questionnaires;UID=questionnaire;PWD=Pembroke")
cgi = CGI.new
questionnaireID = cgi["QuestionnaireID"]
#
# Create a new response in the database
#
db.execute(" insert into response (Comments, QuestionnaireID) values ('#{cgi['FurtherComments'].escape_single_quotes}', #{questionnaireID}) " )
responseID = db.select_one('select SCOPE_IDENTITY() as ResponseID')['ResponseID']
#
# Record the answers in the database
#
print '<table class="answers">'
questions = db.select_all( " select *
from question inner join [type]
on question.TypeID = [type].TypeID
where question.QuestionnaireID = #{questionnaireID}
order by question.QuestionNumber" )
questions.each do |question|
answerType = question['BaseType']
#publish = cgi[question['QuestionNumber'].to_s() + "_publish"]
#if publish == 'on'
# publish = '0'
#else
# publish = '1'
#end
if answerType == 'radio' or answerType == 'checkbox' or answerType == 'select' or answerType == 'selectMultiple' then
comment = ''
if question['Other'] != nil and question['Other'].to_s() != ''
comment = cgi[question['QuestionNumber'].to_s() + "_text"]
end
if answerType == 'checkbox' or answerType == 'selectMultiple' then
answers = cgi.params[question['QuestionNumber'].to_s()]
if answers.length == 0 then
db.execute( "insert into answer (QuestionID, ResponseID, OptionID, Value, Comment)
values ( #{question['QuestionID']},
#{responseID},
NULL,
'',
'#{comment.escape_single_quotes}') " )
else
answers.each do |answer|
db.execute( "insert into answer (QuestionID, ResponseID, OptionID, Value, Comment)
values ( #{question['QuestionID']},
#{responseID},
#{answer.escape_single_quotes},
'',
'#{comment.escape_single_quotes}') " )
answerText = db.select_one( " select [Option]
from [option]
where OptionID = #{answer} " )
#hack for publishing checkboxes
editedQuestion = (question['Question'].to_s()).gsub('Please tick the box below if you do not wish your ', '')
editedQuestion = editedQuestion.gsub('Please tick the box below if you do not wish any of your ', '')
print "<tr><td id=\"question#{question['QuestionNumber']}\">#{editedQuestion}</td><td id=\"answer#{question['QuestionNumber']}\">#{answerText['Option']}"
if comment != ''
print " " + comment
end
print "</td></tr>"
end
end
else
answer = 'NULL'
if cgi[question['QuestionNumber'].to_s()] != nil and cgi[question['QuestionNumber'].to_s()].to_s() != ''
answer = cgi[question['QuestionNumber'].to_s()]
end
answerText = db.select_one( " select [Option]
from [option]
where OptionID = #{answer} " )
print "<tr><td id=\"question#{question['QuestionNumber']}\">#{question['Question']}</td><td id=\"answer#{question['QuestionNumber']}\">#{answerText['Option']}"
if comment != ''
print " " + comment
end
#if publish == '0'
# print " <em>(not for publication)</em>"
#end
print "</td></tr>"
db.execute( " insert into answer (QuestionID, ResponseID, OptionID, Value, Comment)
values ( #{question['QuestionID']},
#{responseID},
#{answer},
'',
'#{comment.escape_single_quotes}') " )
end
elsif answerType == 'strings' or answerType == 'string' or answerType == 'stringsLong' or answerType == 'date' then
answer = cgi[question['QuestionNumber'].to_s()]
if answerType == 'date' and answer == 'dd.mm.yyyy'
answer = ''
else
db.execute( " insert into answer (QuestionID, ResponseID, Value, Comment)
values ( #{question['QuestionID']},
#{responseID},
'',
'#{answer.escape_single_quotes}') " )
end
print "<tr><td id=\"question#{question['QuestionNumber']}\">#{question['Question']}</td><td id=\"answer#{question['QuestionNumber']}\">#{answer}"
#if publish == '0'
# print " <em>(not for publication)</em>"
#end
print "</td></tr>"
elsif answerType == 'yearTerm'
answerYear = cgi[question['QuestionNumber'].to_s() + "_year"]
answerTermNumber = cgi[question['QuestionNumber'].to_s() + "_term"]
answerTerm = ''
if answerTermNumber == '3'
answerTerm = 'Michaelmas'
elsif answerTermNumber == '1'
answerTerm = 'Lent'
elsif answerTermNumber == '2'
answerTerm = 'Summer'
end
separator = '/'
if answerYear != 'yyyy'
db.execute( " insert into answer (QuestionID, ResponseID, Value, Comment)
values ( #{question['QuestionID']},
#{responseID},
'',
'#{answerYear.escape_single_quotes}.#{answerTermNumber}') " )
else
answerYear = ''
if answerTerm == 'Michaelmas'
answerTerm = ''
separator = ''
end
end
print "<tr><td id=\"question#{question['QuestionNumber']}\">#{question['Question']}</td><td id=\"answer#{question['QuestionNumber']}\">#{answerYear.escape_single_quotes}#{separator}#{answerTerm}"
#if publish == '0'
# print " <em>(not for publication)</em>"
#end
print "</td></tr>"
elsif answerType == 'children'
answerSons = cgi[question['QuestionNumber'].to_s() + "_sons"]
answerDaughters = cgi[question['QuestionNumber'].to_s() + "_daughters"]
if answerSons == ''
answerSons = '0'
end
if answerDaughters == ''
answerDaughters = '0'
end
db.execute( " insert into answer (QuestionID, ResponseID, Value, Comment)
values ( #{question['QuestionID']},
#{responseID},
'',
'#{answerSons.escape_single_quotes}s #{answerDaughters.escape_single_quotes}d') " )
print "<tr><td id=\"question#{question['QuestionNumber']}\">#{question['Question']}</td><td id=\"answer#{question['QuestionNumber']}\">#{answerSons.escape_single_quotes} sons #{answerDaughters.escape_single_quotes} daughters"
#if publish == '0'
# print " <em>(not for publication)</em>"
#end
print "</td></tr>"
end
end
". Detailed Error Information Module CgiModule Notification ExecuteRequestHandler Handler eRuby Error Code 0x00000103
Requested URL http://www.cliftoncollegeuk.com:80/parts/register/thankyou.rhtml Physical Path F:\inetpub\wwwroot\parts\register\thankyou.rhtml Logon Method Anonymous Logon User Anonymous
Most likely causes: The CGI process was shut down or terminated unexpectedly before it finished processing the request. The CGI process has a flaw and does not return a complete set of HTTP headers. Things you can try: Check the event logs on the system to see whether the CGI process is shutting down unexpectedly. Troubleshoot the CGI application to determine why it is not sending a complete set of HTTP headers. Links and More Information
This error occurs when the CGI process handling the request exits before it finishes sending the response to IIS.
View more information