Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Syntax error (missing operator) in query expression

Posted on 2009-05-09
4
Medium Priority
?
270 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

926 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