|
 |
asp_databases thread: Expected end of Statement
Message #1 by Leo Clayton <claytonl@z...> on Wed, 13 Dec 2000 18:17:21 -0500
|
|
--=====================_143268328==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
I am trying to build a SQL statement based upon whether or not there is
something in one of five fields. If there is, then I move the form field
to the table field and set a flag. If the flag is set, then I want to
remove the last comma and finish building my SQL statement (with a WHERE
condition) and execute the statement. Previously, I got an Invalid SQL
Statement error now I am getting the following error and I don't know
why. Can someone check my code out and help me. This is the error message:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/EmployeeMasterStuff/UpdateEmployeeTable.asp, line 20
sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
----------------------------------------------------------------------------
--------^
This is line 20:
sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
This is my code:
<%
Dim objRS, objComm, intNoOfRecords
Dim IsDataMissing
dim sSQL
sSQL = "UPDATE EmployeeTable SET "
if not Request.Form("FirstName") = "" Then
sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
IsDataMissing = 1
elseif not Request.Form("LastName") = "" Then
sSQL = sSQL & "LastName = Request.Form("LastName"), "
IsDataMissing = 1
elseif not Request.Form("Title") = "" Then
sSQL = sSQL & "Title = Request.Form("Title"), "
IsDataMissing = 1
elseIf not Request.Form("Education") = "" Then
sSQL = sSQL & "Education = Request.Form("Education"), "
IsDataMissing = 1
elseIf not Request.Form("JobHistory") = "" Then
sSQL = sSQL & "JobHistory = Request.Form("JobHistory") "
IsDataMissing = 1
End If
'----------------------
'get rid of last comma if there is one
'right(sSQL,1)
If IsDataMissing = 1 Then
sSQL = Right(sSQL,1)
End If
'----------------------
sSQL = sSQL & "WHERE (IDNumber = '"&Session("IDNumber")&"')"
Response.Write (sSQL)
' if data is missing then exit entire stuff here without executing next
commands
if IsDataMissing = 1 then
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = strConnect
objComm.CommandText = sSQL
'"UPDATE EmployeeTable SET FirstName=" & Request.form("FirstName")
& "updatefirstname, LastName=updatelastname, Title=updatetitle,
Education=updateeducation, JobHistory=updatejobhistory WHERE (IDNumber =
'"&Session("IDNumber")&"')"
objComm.CommandType = adCmdText
objComm.Execute (sSQL)
Response.Write "<HR><BR>The UPDATE command has been executed, "
Response.Write "Number of records UPDATED = " & intNoOfRecords &
"<BR>"
Response.Write "<B><U>YOU HAVE JUST UPDATED</U> "
Response.Write (Request.Form("Firstname"))
Response.Write " "
Response.Write (Request.Form("Lastname"))
Response.Write "<U>IN THE EMPLOYEE TABLE.</U></B> "
Set objComm = Nothing
end if
%>
---
FREE SOFTWARE DEVELOPMENT CODE, CONTENT, AND
INSIGHTS IN YOUR INBOX!
Get the latest and best C++, Visual C++, Java, Visual Basic, and XML tips, tools, and
developments from the experts. Sign up for one or more of EarthWeb?s
FREE IT newsletters at http://www.earthweb.com today!
---
You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 14 Dec 2000 18:01:22 +1100
|
|
Leo,
Look at your statement -
> sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
What do you see straight after Request.Form("FirstName")?
You see a , mark, but you're not concantenating that with a &, so what is
ASP supposed to do with it? Your question is a basic scripting question, and
has nothing to do with databases, so I'd suggest posting it on the
beginning-asp list next time.
sSQL = sSQL & "FirstName=" & Request.Form("FirstName") & ", "
will work. IE, the bits between the " marks are string literals that you're
adding to the string, and the stuff outside the " (like
Request.Form("FirstName")) are variables, and you need to concantenate each
string literal and/or variable with a &)
However, I suggest that next time you might want to do some experimentation
on this first before posting it to the list, since it seems like a simple
typo error which you've overlooked.
I'm sorry that this sounds really harsh, but you haven't listed anything
that you've tried to do yourself to solve the problem, so I'm assuming
(maybe incorrectly) that you haven't tried much at all.
Cheers
Ken
----- Original Message -----
From: "Leo Clayton" <claytonl@z...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, December 14, 2000 10:17 AM
Subject: [asp_databases] Expected end of Statement
> I am trying to build a SQL statement based upon whether or not there is
> something in one of five fields. If there is, then I move the form field
> to the table field and set a flag. If the flag is set, then I want to
> remove the last comma and finish building my SQL statement (with a WHERE
> condition) and execute the statement. Previously, I got an Invalid SQL
> Statement error now I am getting the following error and I don't know
> why. Can someone check my code out and help me. This is the error
message:
> Microsoft VBScript compilation error '800a0401'
>
> Expected end of statement
>
> /EmployeeMasterStuff/UpdateEmployeeTable.asp, line 20
>
> sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
> --------------------------------------------------------------------------
--
> --------^
>
---
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS? Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development,
Web Development, Networking & Communications, and Hardware & Systems.
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #3 by "John F. Doran" <john@d...> on Thu, 14 Dec 2000 02:06:29 -0500
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0074_01C06572.796F7A80
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
This is line 20:
sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
[John F. Doran]
Try This:
sSQL = sSQL & "FirstName=" & Request.Form("FirstName") & ", "
---
FREE WEB DEVELOPMENT CODE, CONTENT, AND INSIGHTS
IN YOUR INBOX!
Get the latest and best HTML, XML, and JavaScript tips, tools, and
developments from the experts. Sign up for one or more of EarthWeb's
FREE IT newsletters at http://www.earthweb.com today!
---
You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com
Message #4 by "DiAlberto, Allen J." <adialberto@b...> on Thu, 14 Dec 2000 05:40:06 -0500
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C065BA.39187340
Content-Type: text/plain;
charset="iso-8859-1"
Try this
sSQL = sSQL & "FirstName =" & Request.Form("FirstName") & ", "
-----Original Message-----
From: Leo Clayton [mailto:claytonl@z...]
Sent: Wednesday, December 13, 2000 6:17 PM
To: ASP Databases
Subject: [asp_databases] Expected end of Statement
I am trying to build a SQL statement based upon whether or not there is
something in one of five fields. If there is, then I move the form field to
the table field and set a flag. If the flag is set, then I want to remove
the last comma and finish building my SQL statement (with a WHERE condition)
and execute the statement. Previously, I got an Invalid SQL Statement error
now I am getting the following error and I don't know why. Can someone
check my code out and help me. This is the error message:
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/EmployeeMasterStuff/UpdateEmployeeTable.asp, line 20
sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
----------------------------------------------------------------------------
--------^
This is line 20:
sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
This is my code:
<%
Dim objRS, objComm, intNoOfRecords
Dim IsDataMissing
dim sSQL
sSQL = "UPDATE EmployeeTable SET "
if not Request.Form("FirstName") = "" Then
sSQL = sSQL & "FirstName =" &Request.Form("FirstName"), "
IsDataMissing = 1
elseif not Request.Form("LastName") = "" Then
sSQL = sSQL & "LastName = Request.Form("LastName"), "
IsDataMissing = 1
elseif not Request.Form("Title") = "" Then
sSQL = sSQL & "Title = Request.Form("Title"), "
IsDataMissing = 1
elseIf not Request.Form("Education") = "" Then
sSQL = sSQL & "Education = Request.Form("Education"), "
IsDataMissing = 1
elseIf not Request.Form("JobHistory") = "" Then
sSQL = sSQL & "JobHistory = Request.Form("JobHistory") "
IsDataMissing = 1
End If
'----------------------
'get rid of last comma if there is one
'right(sSQL,1)
If IsDataMissing = 1 Then
sSQL = Right(sSQL,1)
End If
'----------------------
sSQL = sSQL & "WHERE (IDNumber = '"&Session("IDNumber")&"')"
Response.Write (sSQL)
' if data is missing then exit entire stuff here without executing next
commands
if IsDataMissing = 1 then
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = strConnect
objComm.CommandText = sSQL
'"UPDATE EmployeeTable SET FirstName=" & Request.form("FirstName") &
"updatefirstname, LastName=updatelastname, Title=updatetitle,
Education=updateeducation, JobHistory=updatejobhistory WHERE (IDNumber
'"&Session("IDNumber")&"')"
objComm.CommandType = adCmdText
objComm.Execute (sSQL)
Response.Write "<HR><BR>The UPDATE command has been executed, "
Response.Write "Number of records UPDATED = " & intNoOfRecords &
"<BR>"
Response.Write "<B><U>YOU HAVE JUST UPDATED</U> "
Response.Write (Request.Form("Firstname"))
Response.Write " "
Response.Write (Request.Form("Lastname"))
Response.Write "<U>IN THE EMPLOYEE TABLE.</U></B> "
Set objComm = Nothing
end if
%>
---
FREE SOFTWARE DEVELOPMENT CODE, CONTENT, AND
INSIGHTS IN YOUR INBOX!
Get the latest and best C++, Visual C++, Java, Visual Basic, and XML tips,
tools, and
developments from the experts. Sign up for one or more of EarthWeb?s
FREE IT newsletters at http://www.earthweb.com today!
leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com
---
FREE WEB DEVELOPMENT CODE, CONTENT, AND INSIGHTS
IN YOUR INBOX!
Get the latest and best HTML, XML, and JavaScript tips, tools, and
developments from the experts. Sign up for one or more of EarthWeb's
FREE IT newsletters at http://www.earthweb.com today!
---
You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com
|
|
 |