Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Help! Expected end of statement
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Help! Expected end of statement

 Post Reply Post Reply Page  <123>
Author
Greaser View Drop Down
Newbie
Newbie


Joined: 30 October 2002
Location: United States
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greaser Quote  Post ReplyReply Direct Link To This Post 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...

 

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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

Contribute to the working anarchy we fondly call the Internet
Back to Top
Greaser View Drop Down
Newbie
Newbie


Joined: 30 October 2002
Location: United States
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greaser Quote  Post ReplyReply Direct Link To This Post 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");
------------------------------------------------------------------------------------------------------^

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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"))
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Greaser View Drop Down
Newbie
Newbie


Joined: 30 October 2002
Location: United States
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greaser Quote  Post ReplyReply Direct Link To This Post 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"
%>

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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"))
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply Page  <123>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.