简体   繁体   English

从asp.net中的SqlDataSource获取更新语法错误

[英]Getting an update syntax error from a SqlDataSource in asp.net

I keep getting a syntax error when trying to run an update query in a SqlDataSource in asp.net. 尝试在asp.net的SqlDataSource中运行更新查询时,我一直收到语法错误。

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. 所有表都保存在MS Access 2010文件中,所有参数都保存在会话中,但是我认为这无关紧要,因为这只是语法错误。

Any help would be appreciated. 任何帮助,将不胜感激。

User and password are MS Access reserved words , I'd suggest using square brackets for the table name and all of the column names: UserpasswordMS Access保留字 ,我建议对表名和所有列名使用方括号:

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

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 我认为@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. 另外:在SQL Server中, User是保留关键字-因此在SQL Server中,您需要使用[User]作为表名。 Not sure if that applies to MS Access, too. 不确定是否也适用于MS Access。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM