INSERT INTO... sql query error

Associate
Joined
12 Aug 2004
Posts
1,009
Location
Glasgow, Scotland
Hi there,

Just wondering if theres something i'm doing wrong with this sql query:

Code:
Set objAdminUsersInsert = objConn.execute("INSERT INTO tblUsers (UserFullName,UserEmail,UserLevel,Username,UserPassword) VALUES ('"& UserFullName &"','"& UserEmail &"','"& UserLevel &"','"& Username &"','"& UserPassword &"') WHERE UserID = "& id &"")

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Missing semicolon (;) at end of SQL statement.
/test/thepines/Website/admin/usersInsertEdit.asp, line 13
I'm trying to edit a row in a database and not sure if i'm using the WHERE clause correctly? I've got it working without using it, so I can insert a new user, but now that i'm trying to edit an already existing one i'm having an error :confused:

Thanks for any help :)
 
do a response.write () on everything inside your execute bracket, that way you'll see a print out of everything, and spot the mistake easier.
 
Hi,

Do you want to be doing an UPDATE rather than an INSERT if you want to modify a row of data that already exists? For example:

UPDATE tblUsers
SET userfullname = namehere
WHERE userid = useridinhere

Hope that helps.

Jim
 
Im not too good at sql, but shouldnt it be:
WHERE UserID = '"& id &"'")

instead of WHERE UserID = "& id &"") ?

Not sure if this will solve it, but this looked dodgy to me
 
WHERE UserID = "& id)

is it not?

you shouldnt need the speechys round a number(int)

best thing i can recommend to do in this case if your not sure is as above basically response.write out the sql and finetune it in Query analyser to make sure the statement is right.
 
Last edited:
JIMA said:
Hi,

Do you want to be doing an UPDATE rather than an INSERT if you want to modify a row of data that already exists? For example:

UPDATE tblUsers
SET userfullname = namehere
WHERE userid = useridinhere

Hope that helps.

Jim

Cheers mate ... I new i wasen't using SQL to its full potential :p

Working perfectly now, thanks a lot :)
 
Back
Top Bottom