Print Page | Close Window

Help! Expected end of statement

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=4310
Printed Date: 30 March 2026 at 9:36am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Help! Expected end of statement
Posted By: Greaser
Subject: Help! Expected end of statement
Date Posted: 17 July 2003 at 9:05pm

I have been working on this isssue for the last 12 hours and need help.... 

I am getting the following error:

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/lab/test/testTicker.asp, line 38, column 177
strTicker = "insert into ticker1 values ('" & request.QueryString("line") & "'), ('" & request.QueryString("text") & "') WHERE line =('" & request.QueryString("line") & "')";
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^

<%
'Dimension variables
Dim adoCon    'Holds the Database Connection Object
Dim rsUpdateEntry 'Holds the recordset for the record to be updated
Dim strSQL   'Holds the SQL query for the database
Dim lngRecordNo  'Holds the record number to be updated
Dim BuildType

'Read in the record number to be updated
lngRecordNo = CLng(Request.Form("ID_no"))

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("ticker.mdb")

'Create an ADO recordset object
Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strTicker = "insert into ticker1  values ('" & request.QueryString("line")  & "'), ('" & request.QueryString("text")  & "') WHERE line =('" & request.QueryString("line")  & "')"

'Set the cursor type we are using so we can navigate through the recordset
rsUpdateEntry.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsUpdateEntry.LockType = 3

'Open the tblComments table using the SQL query held in the strSQL varaiable
rsUpdateEntry.Open strTicker, adoCon

'Update the record in the recordset
rsUpdateEntry.Fields("line") =  request.querystring("line")


'Write the updated recordset to the database
rsUpdateEntry.Update

'Reset server objects
rsUpdateEntry.Close
Set rsUpdateEntry = Nothing
Set adoCon = Nothing


'Return to the update select page incase another record needs deleting
Response.Redirect "tAdmin.asp"

%>

Any help wold be appreciated....thanks in advance.

 

 



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble



Replies:
Posted By: KCWebMonkey
Date Posted: 17 July 2003 at 9:18pm
don't you need another quote at the end to end the strTicker string?


Posted By: Greaser
Date Posted: 17 July 2003 at 9:28pm
Nope - that didn't work.  Thanks though.

-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble


Posted By: MorningZ
Date Posted: 17 July 2003 at 9:33pm
learn how to code an INSERT statement.. there is no place for "where" clauses

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: MorningZ
Date Posted: 17 July 2003 at 9:34pm
http://www.w3schools.com/sql/sql_insert.asp - http://www.w3schools.com/sql/sql_insert.asp

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Greaser
Date Posted: 17 July 2003 at 9:42pm

I have been learning my SQL ... yes... that is why I am asking for help because I know my syntax is not right.

I have changed me code and am still receiving :

strTicker = "insert into ticker1  values ('" & request.QueryString("line")  & "'), ('" & request.QueryString("text")  & "')" ;

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/lab/test/testTicker.asp, line 38, column 125
strTicker = "insert into ticker1 values ('" & request.QueryString("line") & "'), ('" & request.QueryString("text") & "')" ;
----------------------------------------------------------------------------------------------------------------------------^

Any Ideas?



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble


Posted By: Greaser
Date Posted: 17 July 2003 at 11:15pm

Thanks for everyones help on this.

I am now sooooo close I can taste it.

 

Here is my error now.

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/lab/test/testTicker.asp, line 32
 

Line 32 is highlighted in red.

<%
'Dimension variables
Dim adoCon    'Holds the Database Connection Object
Dim rsUpdateEntry 'Holds the recordset for the record to be updated
Dim strSQL   'Holds the SQL query for the database
Dim lngRecordNo  'Holds the record number to be updated


'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("ticker.mdb")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "UPDATE ticker1 SET line = '" & request.QueryString("line") & "', text = 'this is a test'   WHERE line = '" & request.QueryString("line") &"';"

'Open the tblComments table using the SQL query held in the strSQL varaiable
rsUpdateEntry.Open strSQL, adoCon

'rsUpdateEntry.Fields("line") =  request.querystring("line")
rsUpdateEntry.Fields("text") =  request.querystring("text")

'Return to the update select page incase another record needs deleting
Response.Redirect "tAdmin.asp"


Set adoCon = nothing
%>

 

Thanks again for the help in advance.



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble


Posted By: MorningZ
Date Posted: 18 July 2003 at 5:35am

its help if we knew what the heck you were trying to do...

so far with the same piece of code, i've seen you try to insert, i've seen you try to update, and i dont know what the ___ you are trying to later on.... its all wrong....

i'll try to help with a little from earlier:

strTicker = "insert into ticker1  values ('" & request.QueryString("line")  & "'), ('" & request.QueryString("text")  & "')" ;

not sure where you got that sytax from, but you need to either (1) burn that book, or (2) wipe that bookmark off your hard drive, and then check out the syntax on the link i have above

its:
INSERT INTO Table_Name_Goes_Here ( Column1_to_Insert, Col2_to_Insert, Col3_to_Insert ) VALUES ( Col1_Value, Col2_Value, Col3_Value )

with the ColX_to_Insert NOT having quotes around them, and the ColX_Value having quotes depending on what kind of data field

trust me man, take 20 mins of your time and go through the tutorials at http://www.w3schools.com/sql/default.asp - http://www.w3schools.com/sql/default.asp , you'll save yourself soooooooooooooooo much frustration of just randomly trying stuff (and failing miserably)



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Greaser
Date Posted: 18 July 2003 at 7:41am

I understand the general syntax.  What is throughing my off is passing the data through the querystring.

If I use the query analyzier I can get it to work.  But in asp I can't. 

Here is all I am trying to do.  I have two fields on a form, field "line" and field "text".  I am just trying to update the "text" where "line" number = "x".  Does that make sense?

ex: whatevermypageis.asp?line=1&text=this+is+a+test

I need to update the database of column "line" and place in the data of "text".  What I am trying to do I know is simple. 

Thanks again...

 



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble


Posted By: MorningZ
Date Posted: 18 July 2003 at 8:32am

"I am just trying to update the "text" where "line" number = "x".  Does that make sense?"

theres the keyword there... you are trying to "UPDATE" not "INSERT"

so the proper SQL string to run would be like:

strTicker = "UPDATE ticker1 SET [text] = '" & Replace( Request.QueryString("text"),"'","''" ) & "'" WHERE line = " & Cint( Request.QueryString("line")

then

adoCon.Execute( strTicker )

will do the trick, screw all that ADO update stuff....

Note that the above SQL string protects a bit against SQL Injection attacks (search that term on google if you want to know what that's about), and also absolutely assumes that both fields will be on the querystring, if someone doesn't pass a line #, it'll bomb

also note the "[text]", its veeeeery bad practice to use common keywords as field names, especially if you are using Access.....
here's a list of ODBC keywords to avoid like the plague:
http://www.flws.com.au/showusyourcode/codeLib/code/odbc_keywords.asp - http://www.flws.com.au/showusyourcode/codeLib/code/odbc_keywords.asp



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Greaser
Date Posted: 18 July 2003 at 9:18am

I appreciate you help on this...  your an asset to WebWiz!

I don't mean to be such a rookie on this.

<%
'Dimension variables
Dim adoCon    'Holds the Database Connection Object
Dim rsUpdateEntry 'Holds the recordset for the record to be updated
Dim strTicker   'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("ticker.mdb")

'Initialise the strSQL variable with an SQL statement to query the database
strTicker = "UPDATE ticker1 SET [text] = '" & Replace( Request.QueryString("TicText"),"'","''" ) & "'" WHERE line = " & Cint( Request.QueryString("line");" _ Is the only thing I have added.  And I ahve tried not having it and making the ; after the ".

adoCon.Execute( strTicker )


'rsUpdateEntry.Fields("line") =  request.form("line")
'rsUpdateEntry.Fields("text") =  request.form("TicText")

'Return to the update select page incase another record needs deleting
Response.Redirect "tAdmin.asp"

'Reset server objects
rsUpdateEntry.Close
Set rsUpdateEntry = Nothing
Set adoCon = Nothing
%>

 

Still produces:

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/lab/test/testTicker.asp, line 31, column 103
strTicker = "UPDATE ticker1 SET [text] = '" & Replace( Request.QueryString("TicText"),"'","''" ) & "'" WHERE line = " & Cint( Request.QueryString("line");
------------------------------------------------------------------------------------------------------^



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble


Posted By: ljamal
Date Posted: 18 July 2003 at 10:14am
You need to check your parantheses

strTicker = "UPDATE ticker1 SET [text] = '" &_
Replace( Request.QueryString("TicText"),"'","''" )&_
"'" WHERE line = " & Cint( Request.QueryString("line"))

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: MorningZ
Date Posted: 18 July 2003 at 10:18am

not sure why you are so intent on putting a semicolon at the end of the SQL statement, but Ljamal caught my mistype

also note that you want to clean up objects before you redirect away, otherwise i don't think (someone correct me if i am wrong) those lines get run



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Greaser
Date Posted: 18 July 2003 at 10:24am

Here is what I am getting now.

I am using ljamal's statement

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/lab/test/testTicker.asp, line 35, column 4
"'" WHERE line = " & Cint( Request.QueryString("line"))
---^

<%
'Dimension variables
Dim adoCon    'Holds the Database Connection Object
Dim rsUpdateEntry 'Holds the recordset for the record to be updated
Dim strTicker   'Holds the SQL query for the database

'Create an ADO connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("ticker.mdb")

'Initialise the strSQL variable with an SQL statement to query the database


strTicker = "UPDATE ticker1 SET [text] = '" &_
Replace( Request.QueryString("TicText"),"'","''" )&_
"'" WHERE line = " & Cint( Request.QueryString("line"))

adoCon.Execute( strTicker )


'rsUpdateEntry.Fields("line") =  request.form("line")
rsUpdateEntry.Fields("text") =  request.form("TicText")

'Reset server objects
rsUpdateEntry.Close
Set rsUpdateEntry = Nothing
Set adoCon = Nothing

'Return to the update select page incase another record needs deleting
Response.Redirect "tAdmin.asp"
%>



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble


Posted By: ljamal
Date Posted: 18 July 2003 at 10:26am
Use this:
strTicker = "UPDATE ticker1 SET [text] = '" &_
Replace( Request.QueryString("TicText"),"'","''" )&_
"' WHERE line = " & Cint( Request.QueryString("line"))

instead of this:
strTicker = "UPDATE ticker1 SET [text] = '" &_
Replace( Request.QueryString("TicText"),"'","''" )&_
"'" WHERE line = " & Cint( Request.QueryString("line"))

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: MorningZ
Date Posted: 18 July 2003 at 10:32am

aggg...

my head just spins dizzy out of control when i see the utter lack of effort given by some people.......

greaser.. if you are even remotely serious about coding, you have to learn to take a little bit of initive and see what error codes mean..... just a little bit......  after all, the error message POINTS right to where it sees an issue!!  fix it



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Greaser
Date Posted: 18 July 2003 at 10:54am

Lack of effort isn't what the issue is...  believe me I have been busting my hump the last 24 hours looking, researching and trying to understand what gets single quotes and what gets double quotes.  On double quote is really easy to miss when you are LEARNING this.  Isn't this what this site is all about?

And believe me before I come looking for help I do try to answer all questons my self. 

Thanks.. 



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble


Posted By: Greaser
Date Posted: 18 July 2003 at 11:28am

Wahoo! 

Finally it works!!!

Thank you MorningZ and ljamal for all you help, wisdom and criticism .  THANK YOU THANK YOU THANK YOU!!!!!

Have a good weekend.

 

<%

'Dimension variables

Dim adoCon                              'Holds the Database Connection Object

Dim rsUpdateEntry         'Holds the recordset for the record to be updated

Dim strTicker                             'Holds the SQL query for the database

 

'Create an ADO connection odject

Set adoCon = Server.CreateObject("ADODB.Connection")

 

'Set an active connection to the Connection object using a DSN-less connection

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("ticker.mdb")

 

'Initialise the strSQL variable with an SQL statement to query the database

 

strTicker = "UPDATE ticker1 SET [ticText] = '" Replace( Request.QueryString("TicText"),"'","''" ) "' WHERE line = " & Cint( Request.QueryString("line"))

 

adoCon.Execute( strTicker )

 

'Reset server objects

 

Set adoCon = Nothing

 

'Return to the update select page incase another record needs deleting

Response.Redirect "tAdmin.asp"

%>

 



-------------
'Computers don't make errors...what they do, they do on purpose.' - Dale Gribble



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net