Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,841 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,616 people online right now. Registration is fast and FREE... Join Now!




Coldfusion 8 UPDATE

 
Reply to this topicStart new topic

Coldfusion 8 UPDATE, Syntax Error

wblakenc
17 Jul, 2008 - 12:45 PM
Post #1

New D.I.C Head
*

Joined: 17 Jul, 2008
Posts: 6



Thanked: 1 times
My Contributions
Ok I am having an issue with a fairly simple piece of code. I want users to be able to update their password using a online form. So I have created:

CODE

<cfquery datasource="Users" name="change_passwords">
UPDATE login
SET password ='anotherTest'
WHERE aUser ='will'
</cfquery>



I get the following error:

CODE

Error Executing Database Query.
Syntax error in UPDATE statement.

The error occurred in C:\Inetpub\wwwroot\workflow\update_password.cfm: line 1

1 : <cfquery datasource="Users" name="change_passwords">
2 : UPDATE login
3 : SET password ='anotherTest'

SQLSTATE       
SQL        UPDATE login SET password ='anotherTest' WHERE aUser ='will'
VENDORERRORCODE       3092
DATASOURCE       Users



Just for reference login is the table inside an access database called 'Users'. Obviously the user 'will' and password 'anotherTest' was typed in just to make sure it was not a problem accepting dynamic data. Normally that data would be entered from a form.

Other bits of information, the CF server is a computer found on my local network which is running windows server 2003 and has an access 2003 database on it. The database is connected to CF and works in every way except when I use this UPDATE command.

Any ideas?!?! I am ready to pull my hair out.
User is offlineProfile CardPM
+Quote Post

wblakenc
RE: Coldfusion 8 UPDATE
17 Jul, 2008 - 01:21 PM
Post #2

New D.I.C Head
*

Joined: 17 Jul, 2008
Posts: 6



Thanked: 1 times
My Contributions
Ok it seems to be a problem with either ms access or the server it is on. Because out of shear madness I uploaded the CF code to our online server which uses MySQL and Apache the code works....

Very strange. Anyone know why this does not work on Access but does on MySQL?
User is offlineProfile CardPM
+Quote Post

sansclue
RE: Coldfusion 8 UPDATE
18 Jul, 2008 - 04:51 AM
Post #3

D.I.C Head
**

Joined: 21 Nov, 2007
Posts: 113



Thanked: 7 times
My Contributions
QUOTE(wblakenc @ 17 Jul, 2008 - 02:21 PM) *

Very strange. Anyone know why this does not work on Access but does on MySQL?


I would guess that you are using a reserved word as a column or table name. The likely suspect is "password". I don't know about "login". Try using [ ] around the table and column name.

CODE

UPDATE [login]
SET [password] ='anotherTest'
WHERE aUser ='will'


If that fixes the error, you have your answer. It is best not to use reserved words, if you can help it. So the best solution is to rename the objects permanently. If that is not possible use the [ ]. Of course that means you have to use them every time you reference the table or column in a query.

This post has been edited by sansclue: 18 Jul, 2008 - 04:51 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 05:33PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month