Solved

Syntax error (missing operator) in query expression

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
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 is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

19 Experts available now in Live!

Get 1:1 Help Now