Solved

Syntax error (missing operator) in query expression

Posted on 2009-05-09
4
259 Views
Last Modified: 2012-05-06
I'm having trouble updating record set.  I get an syntax error on the id.

I request an querystring like this:  NO=request.querystring("id")

I load a content like this:
set adoRs = adoCn.Execute("Select * From Videos where id=" & NO)
and that works perfectly.

When I try to update the data I get an error.
This is the code for the update:

  sAuthor = Replace(Request.Form("AUTHOR"),"'","''")

  sTitle = Replace(Request.Form("TITLE"),"'","''")

  sContent = Replace(Request.Form("txtContent"),"'","''")

  adoCn.Execute "Update VIDEOS set DESCRIPTION='" & sContent & "', AUTHOR='" & sAuthor & "', TITLE='" & sTitle & "' where id= & NO &"'"

  end if
 

The error I get is:

Syntax error (missing operator) in query expression 'id= & NO &'.

Open in new window

0
Comment
Question by:GDB08
  • 3
4 Comments
 
LVL 29

Accepted Solution

by:
Badotz earned 500 total points
ID: 24346032
You have an unterminated string.
'' If NO is a nemeric field:
 

adoCn.Execute "Update VIDEOS set DESCRIPTION='" & sContent & "', AUTHOR='" & sAuthor & "', TITLE='" & sTitle & "' where id=" & NO
 
 

'' If NO is a text field:
 

adoCn.Execute "Update VIDEOS set DESCRIPTION='" & sContent & "', AUTHOR='" & sAuthor & "', TITLE='" & sTitle & "' where id='" & NO &"'"

Open in new window

0
 
LVL 5

Expert Comment

by:Abiel de Groot
ID: 24346043
You have put the single comma in the wrong place. A string is put like this

Where No '" & sAuthor & "'

You have put this:

Where No "' & sAuthor & '" '<<< you need the single quote outside the double quotes.


Also... if AUTHOR is a number (int) Then do not put a single quote outside the double quotes. The single quote deliminates a string not a number.

A.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 24346073
@Jonbysoft: I sure don't see where the asker made that error.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 24347009
No worries - glad to help.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now