Solved

Syntax error (missing operator) in query expression

Posted on 2009-05-09
4
265 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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