ExecuteNonQuery() throws “Incorrect syntax near the keyword 'User'”

倾然丶 夕夏残阳落幕 提交于 2019-12-02 05:46:18

You've got a table with the name "User", but that's a reserved keyword.

You could rename the table, or enclose it in brackets when you reference it:

string commandText = "INSERT INTO [User] (firstName ...

Change the table name from "User" to something else because User is a reserved keyword that cannot be used again, so if you use any other name for table the code will work fine example:-

create table User1(firstName varchar(20),lastName varchar(20),adress varchar(20),town varchar(20),favoriteCurrency int)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!