Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update code 1

Status
Not open for further replies.

peter11

Instructor
Mar 16, 2001
334
US
My goal is to copy image names from one table to another table where the first and last names are matching. I must have some silly mistake but i am suffering from tunnel vision at this point,

+++++++++++++++++++++++++++++++++++=
Here is the code
<cfquery datasource="publication" name="pics">
SELECT s.lastname , s.firstname, p.lastname , p.firstname, p.image
FROM picnames p inner join students s on s.lastname = p.lastname and s.firstname = p.firstname
</cfquery>

<cfloop query="pics">
<cfoutput><CFQUERY datasource="publication">
UPDATE students
SET imagename = #pics.image#

WHERE lastname = #pics.lastname# and firstname=#pics.firstname#
</CFQUERY></cfoutput>
</cfloop>

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Here is the error

ODBC Error Code = 37000 (Syntax error or access violation)

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '000002.tif'.

The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (7:12) to (7:45).

 
You need single quotes around your variables if they're not a numeric datatype
Code:
SET imagename = [red]'[/red]#pics.image#[red]'[/red]
WHERE lastname =  [red]'[/red]#pics.lastname#[red]'[/red] and firstname=[red]'[/red]#pics.firstname#[red]'[/red]

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Actually, it would be even better if you used cfqueryparm. [thumbsup2]

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top