Question

Locked

ASP Survey Problems (SQL Database)

By rouschkateer ·
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 %>
<html>
<head>
<title>Pennsylvania School of Business Student Survey - ASP Page</title>
</head>
<body>
<%
'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")
%>
<script language="vbscript" runat="server">
'Variable Declarations
Dim TextLine,FldName,FldVal As String
Dim x,NumVar,WA,EQ,IG,IK,SMC,SMP,AQ,DIS,IH,TQ,PR,OE As Integer
Dim EqPos,LineLen,fldLen As Integer

Dim FILE_NAME As String = "C:\survey\survey.txt"

'Dim objReader As New System.IO.StreamReader(FILE_NAME)

FileOpen(1, FILE_NAME, OpenMode.Input) ' Open file.
Do While Not EOF(1) ' Loop until end of file.
TextLine = LineInput(1) ' Read line into variable.

' Do While objReader.Peek() <> -1
' TextLine = objReader.ReadLine()

For x = 1 To 25
TextBox1.Text = Str$(x)


' If x < 6 Then
' GoTo keepgoing
' End If

Trim(TextLine) 'remove spaces at beginning or end
LineLen = Len(TextLine) ' get the lngth of the line
EqPos = InStr(TextLine, "=") ' Find the equal sign

If EqPos = 0 Then GoTo keepgoing

FldName = TextLine.Substring(0, (EqPos - 1))
fldLen = Len(FldName) ' get the lngth of the line
FldVal = TextLine.Substring(EqPos, (LineLen - EqPos))

'diagnostic stuff
TextBox2.Text = FldName
TextBox3.Text = FldVal


If FldName = "WorkArea" Then
txtWorkArea.Enabled = True
txtWorkArea.Text = FldVal
WA = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "Equipment" Then
txtEquipment.Enabled = True
txtEquipment.Text = FldVal
EQ = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "Environment" Then
txtEnv_Comments.Enabled = True
txtEnv_Comments.Text = FldVal
x = 25
GoTo keepgoing
End If

If FldName = "Instructor" Then
txtInstructor.Enabled = True
txtInstructor.Text = FldVal
x = 25
GoTo keepgoing
End If

If FldName = "ClassName" Then
txtClass.Enabled = True
txtClass.Text = FldVal
x = 25
GoTo keepgoing
End If

If FldName = "ClassTime" Then
txtDay.Enabled = True
txtDay.Text = FldVal
x = 25
GoTo keepgoing
End If

If FldName = "Term" Then
txtClassTime.Enabled = True
txtClassTime.Text = FldVal
x = 25
GoTo keepgoing
End If

If FldName = "InstrGreet" Then
txtInstrGreet.Enabled = True
txtInstrGreet.Text = FldVal
IG = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "InstrKnow" Then
txtInstrKnow.Enabled = True
txtInstrKnow.Text = FldVal
IK = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "SubMatter" Then
txtSubMatCon.Enabled = True
txtSubMatCon.Text = FldVal
SMC = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "SubPres" Then
txtSubMatPres.Enabled = True
txtSubMatPres.Text = FldVal
SMP = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "AskQ" Then
txtAskQuest.Enabled = True
txtAskQuest.Text = FldVal
AQ = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "Discipline" Then
txtDiscipline.Enabled = True
txtDiscipline.Text = FldVal
DIS = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "IndHelp" Then
txtIndHelp.Enabled = True
txtIndHelp.Text = FldVal
IH = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "InstrComment" Then
txtInstrCom.Enabled = True
txtInstrCom.Text = FldVal
x = 25
GoTo keepgoing
End If

If FldName = "Tutoring" Then
txtTutor.Enabled = True
txtTutor.Text = FldVal
x = 25
GoTo keepgoing
End If

If FldName = "TutorQ" Then
txtTutorQUal.Enabled = True
txtTutorQUal.Text = FldVal
TQ = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "ProgPres" Then
txtProgRep.Enabled = True
txtProgRep.Text = FldVal
PR = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "Overall" Then
txtOverall.Enabled = True
txtOverall.Text = FldVal
OE = CInt(FldVal)
x = 25
GoTo keepgoing
End If

If FldName = "GenComment" Then
txtGenComment.Enabled = True
txtGenComment.Text = FldVal
x = 25
GoTo DBLoad
End If


GoTo CloseIt


keepgoing:
Next x

</script>
<%
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;"

%>
</body>

</html>

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Lets look at one thing at a time shall we..

by Shellbot In reply to ASP Survey Problems (SQL ...

Sorry..what is it that you are trying to do? Trying to fix the following error, or trying to get a varchar into an integer?
This error would indicate your code is missing something..

"The error I receive is:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/Survey/submit.asp, line 39, column 28"

If this is the first thing you are trying to solve, post lines 37-42 from submit.asp and point out which line is which.

gotta ask mate, is this an internal site or a website? Its just the DBA in me..I shiver to see 'sa' used for anything..and to see it with a password of 'password' is a life sentence....

Collapse -

Thanks dude

by Shellbot In reply to ASP Survey Problems (SQL ...

was great of you to come back here and check up on this. only spent 15 mins looking your code and stuff..and then ask you to provide some more info so i could help you..

no worries, had nothing else to do anyways..

this is why i don't bother with the questions area anymore...no one posts back..or if ya do help..don't get a thumbs for it anyways..

Collapse -

I'm Sorry

by rouschkateer In reply to Thanks dude

I was supposed to get e-mail replied of anyone posted, but I never did, so, yeah, I ASSumed no one replied. My apologies, and I fixed it.

Back to Networks Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums