Solved

Syntax error (missing operator) in query expression

Posted on 2009-05-09
4
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Recordset containing single quotes 8 52
Save ms data to server side. 19 64
Diminish Pop-up  in 3 seconds 7 78
Adding Clickable Links to JQuery Data Items 24 58
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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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