ASP Survey Problems (SQL Database)
I am trying to retrieve database results from an html form page and dump the results into an SQL table. The only problem is that the radio buttons are varchar and the table is looking for intergers so I can calculate the results easier. My boss wants me to use his code to change the varchars into ints. Hopefully, this isn't too long of a code for my fine members to hack out.
I think what is going on is that the programming languages are mixed and the pahge simply doesn;t know what to do.
The error I receive is:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/Survey/submit.asp, line 39, column 28
Here is the code:
<%@ Language="VBScript" %>
<% Option Explicit %>
Pennsylvania School of Business Student Survey - ASP Page
<%
'declare your variables
dim connection,recordset
Dim WorkArea, Equipment, Environment, Instructor, ClassName, ClassTime, Term, InstrGreet, InstrKnow, SubMatter, SubPres, AskQ, Discip
Dim IndHelp, InstrComment, Tutoring, TutorQ, ProgPres, OverAll, GenComment
'Receiving values from Form, assign the values entered to variables
WorkArea = Request.Form("WorkArea")
Equipment= Request.Form("Equipment")
Environment=Request.Form("Environment")
INSTRUCTOR= Request.Form("INSTRUCTOR")
ClassName= Request.Form("ClassName")
ClassTime= Request.Form("ClassTime")
Term= Request.Form("Term")
InstrGreet= Request.Form("InstrGreet")
InstrKnow= Request.Form("InstrKnow")
SubMatter= Request.Form("SubMatter")
SubPres= Request.Form("SubPres")
AskQ= Request.Form("AskQ")
Discip = Request.Form("Discipline ")
IndHelp= Request.Form("IndHelp")
InstrComment= Request.Form("InstrComment")
Tutoring= Request.Form("Tutoring")
TutorQ= Request.Form("TutorQ")
ProgPres= Request.Form("ProgPres")
Overall= Request.Form("Overall")
GenComment= Request.Form("GenComment")
%>
<%
dim SQL, sConnString
'declare SQL statement that will query the database
SQL = "INSERT into surveys (WorkArea, Equipment, Environment, INSTRUCTOR, ClassName, ClassTime, Term, InstrGreet, InstrKnow, SubMatter, SubPres, AskQ, Discip , IndHelp, InstrComment, Tutoring, TutorQ, ProgPres, Overall, GenComment) values ('" & _
WorkArea & "', '" &Equipment& "', '" & Environment& "', '" & _
INSTRUCTOR& "', '" & ClassName& "', '" & ClassTime& "', '" & Term& "', '" & InstrGreet& "', '" & _
InstrKnow& "', '" & SubMatter& "', '" & SubPres& "', '" & _
AskQ& "', '" & Discip & "', '" & IndHelp& "', '" & _
InstrComment& "', '" & Tutoring& "', '" & TutorQ& "', '" & _
ProgPres& "', '" & Overall& "', '" & GenComment& "')"
'define the connection string, specify database
'driver and the location of database
sConnString="DSN=ConSql;Server=psbhelp;Database=survey;UID=sa;Password=password;"
'create an ADO connection and recordset
Set connection = Server.CreateObject("ADODB.Connection")
Set recordset = Server.CreateObject("ADODB.Recordset")
'Open the recordset object, execute the SQL statement
recordset.Open SQL,connection
connection.Open(sConnString)
connection.Execute(SQL)
If recordset.eof then
response.write "There were no records returned."
Else
response.write "There are records returned."
End if
'close the connection and recordset objects freeing up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
'broken code follows below
'declare SQL statement that will query the database
'SQL="SELECT * FROM surveys"
'sConnString="DRIVER={SQL Server};SERVER=192.168.1.254,1433;UID=sa;PWD=password;DATABASE=survey;"
'sConnString="DSN=ConSql;Server=192.168.1.254,1433;Database=survey;Network Library=DBMSSOCN;UID=sa;Password=password;"
%>