tags:

views:

712

answers:

2

I'm getting the following error on the line of code below:

Syntax error (missing operator) in query expression 'REPLACE(LTRIM(RTRIM(ATTACHMENTS)), ,'')'.

Any help would be awesome...

-----------the line of code that is giving me problems--------------------------------

objConn.Execute("UPDATE EMAIL_SEND_ATTACHMENTS set ATTACHMENTS = REPLACE(LTRIM(RTRIM(ATTACHMENTS)), "& StoredPath & " ,'') WHERE EMAIL_LETTERS_HOLD_ID= "& AttID & " ")



-----------------------full asp page being called by a function------------------
<%


Dim AttID, RedirectURL
Dim objConn
dim StoredPath

AttID=request("EMAIL_LETTERS_HOLD_ID")
RedirectURL=request("RedirURL")



Set objConn = CreateObject("ADODB.Connection")
objConn.Open "DSN=AccessDSN"
objConn.Execute("UPDATE EMAIL_SEND_ATTACHMENTS set ATTACHMENTS = REPLACE(LTRIM(RTRIM(ATTACHMENTS)), " & StoredPath & " ,'') WHERE EMAIL_LETTERS_HOLD_ID= "& AttID & " ")
objConn.Close
Set objConn = Nothing

response.redirect RedirectURL
%>
+1  A: 

I think you're missing some quotes - check before and after the StoredPath variable:

objConn.Execute("UPDATE EMAIL_SEND_ATTACHMENTS set ATTACHMENTS = REPLACE(LTRIM(RTRIM(ATTACHMENTS)), '"& StoredPath & "' ,'') WHERE EMAIL_LETTERS_HOLD_ID= "& AttID & " ")

Andy.

cool that worked. but now I'm getting this error:Undefined function 'REPLACE' in expressionis REPLACE not a ms sql server function?
MG
if you try running the statement directly in MS Enterprise manager or Query Analyzer - does it work ?
MG
Your last SQL is incorrect - by removing the REPLACE, you left the LTRIM function with the parameters of REPLACE. Put back the REPLACE and try the SQL statement in Query analyzer... Make it work there and then bring it back to ASP. Also, make sure StoredPath is defined - it should be at least ''.
I've tested my sql statement with replace and it worked fine...storedpath is probably the issue. i've defined it in the main page and made sure it was pulling the right info but there might be a disconnect when i pass it into the function....i'll focus on that now..thanks for the help!
MG
A: 

You're missing quotes:

xxx" & StoredPath & "'xxx where xxx is a ' - the single quote delimiter.

David in Dakota