| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 48927 | 2004-09-05 05:54:00 | ASP Database problem | george12 (7) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 269400 | 2004-09-05 05:54:00 | Hi, I am having trouble with a piece of ASP script . It is ChangePassword . asp for the changin of a user's password on http://www . jgih . com . My code is: Public Function SaveUserData(UserName,Field,Value) Set MyConn = Server . CreateObject("ADODB . Connection") MyConn . Open("PROVIDER=Microsoft . Jet . OLEDB . 4 . 0;DATA SOURCE=c:\Domains\jgih . com\db\users . mdb;") Line 16 -> MyConn . Execute("UPDATE Users SET " & Field & " = '" & Value & "' WHERE UserName = '" & UserName & "'") MyConn . Close Set MyConn = Nothing End Function (the 'Line 16 ->' isn't actually written in the script!) And to actually change the password: SaveUserData UserName,"Password",NewPassword Now, users attempting to change their password get this error: Microsoft JET Database Engine error '80040e14' Syntax error in UPDATE statement . /changepassword . asp, line 16 See above, I have mentioned which is line 16 . The really strange thing is that I use the exact same function in another script, UserChange . asp which is changin other user settings (all except password) . To call it I use this code: SaveUserData UserName,"FirstName",NewFirstName SaveUserData UserName,"LastName",NewLastName SaveUserData UserName,"Email",NewEmail SaveUserData UserName,"WorkPhone",NewWorkPhone SaveUserData UserName,"HomePhone",NewHomePhone SaveUserData UserName,"Address",NewAddress SaveUserData UserName,"BillAddress",NewBillAddress SaveUserData UserName,"ShipAddress",NewShipAddress I have verified that the correct values are being passed to the function, so what is wrong? Thanks in advance, George |
george12 (7) | ||
| 269401 | 2004-09-05 10:47:00 | Please help guys, I want to hopefully get it fixed tonight. *imagines customers taking business elsewhere coz they can't change their password* Cheers |
george12 (7) | ||
| 269402 | 2004-09-05 12:38:00 | One thing you may like to check is that you have the correct permissions set on the database. If you are using IIS you need to ensure that the Internet Guest User Account has write access to do your updates. I just did a quick search on google and here is a site (www.webwizguide.info) with instructions to walk you through how to give write access. The other thing i would try is do a write back to your asp page of the SQL string to confirm that the syntax is correct - NB remember to comment out your offending execute statement. Very easy to get an extra quote or not have enough etc... Cheers Dave |
odyssey (4613) | ||
| 269403 | 2004-09-06 05:21:00 | The error might not be in line 16. The line number given is only where the interpreter had got to when it decided that there was an error. That line may be OK as written, but be getting rubbish from previous operations. Are results of the previous lines substututed into arguments in line 16? I don't know this stuff, but is the ".Jet._OLEDB.4" supposed to have a space where I have put a "_"? Looks a bit iffy to me. ;-) The DATA_SOURCE might be OK because it's in a quoted string ... I don't know. :D |
Graham L (2) | ||
| 269404 | 2004-09-06 08:21:00 | Lol, you're right it does look iffy, but the function is copied and pasted from another working script so it can't be ... can it? Same story with permissions. And you're very right about the line 16 thing, I just can't see what is wrong twith the line calling it. Cheers for the help George |
george12 (7) | ||
| 269405 | 2004-09-06 08:23:00 | Sorry, turns out that there was no space between . and OleDB. Just a bug in my copy-and-pasting. | george12 (7) | ||
| 269406 | 2004-09-06 08:35:00 | OK, added a line to display the SQL statement, and here it is (straight from IE): UPDATE Users SET Password = 'hello' WHERE UserName = 'George' Microsoft JET Database Engine error '80040e14' Syntax error in UPDATE statement . /changepassword . asp, line 17 It's line 17 now but it's the same line I just have the debuger line now . George PS . 'Hello' is NOT my real password |
george12 (7) | ||
| 269407 | 2004-09-06 09:10:00 | > PS. 'Hello' is NOT my real password Gee really, shall I stop trying to h4x0r your account now? Have you checked all your capitilisations are correct? Are you selecting the correct database? Does the user that script is running as have write permission to the database. Try getting some more verbose errors, try running the update query directly against the database instead of in a web-page. |
whiskeytangofoxtrot (438) | ||
| 269408 | 2004-09-06 11:38:00 | Probally is just a syntax error in line 16 or 15, I use dreamweaver and have experienced a similar error. It was very hard to pick but just deleting one of the quotes made it work. | Rob99 (151) | ||
| 269409 | 2004-09-06 11:45:00 | play with changing the quote system and moving of the white space . . . . . try this . . . . UPDATE Users SET Password = "hello" WHERE UserName = "George" BTW should an SQL command end with a ; |
robsonde (120) | ||
| 1 2 3 | |||||