Question

I keep getting a syntax error when trying to run an update query in a SqlDataSource in asp.net.

UPDATE User 
SET userName = @userName, 
    password = @password, 
    UserType = @UserType, 
    datejoined = @datejoined, 
    email = @email, 
    loggedIn = @loggedIn, 
    picFilePath = @picFilePath 
WHERE 
    userName = @userName

All the tables are saved in a MS Access 2010 file and all the parameters are saved in session, but I don't think it's relevant since this is just a syntax error.

Any help would be appreciated.

Was it helpful?

Solution

User and password are MS Access reserved words, I'd suggest using square brackets for the table name and all of the column names:

UPDATE [User]
SET [userName] = @userName, 
    [password] = @password, 
    [UserType] = @UserType, 
    [datejoined] = @datejoined, 
    [email] = @email, 
    [loggedIn] = @loggedIn, 
    [picFilePath] = @picFilePath 
WHERE 
    [userName] = @userName

OTHER TIPS

Is there really a space in here?

loggedIn = @ loggedIn
            ^
            |
            +---> should there be a space here?

I don't think there should be a space between the @ and the loggedIn

In addition: in SQL Server, User is a reserved keyword - so in SQL Server, you need to use [User] for your table name instead. Not sure if that applies to MS Access, too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top