SQL error: Incorrect syntax near the keyword 'User'

User is a reserved keyword, so you must use square brackets to make it explicit that you mean the object named "User" it, i.e. use [User] instead of User.


User is a t-sql reserved keyword. Enclosing it in square brackets should solve this. E.g INSERT INTO [User]


run your query against the database. You can use the declare sql keyword to define your variables and give them values. If you need to figure out the variables values, set a breakpoint at conn.Open and then use the locals window to see what values you are passing in. Another tool at your disposal is the Sql Profiler. You can start a trace then run your program. You should be able to see the query as executed in the profile after the code you have posted has run.

All of this should help you to figure out what is wrong with your sql when the exception does not provide enough information.

The Sql Server Management Studio should have highlighted the User keyword in your sql statement, easily showing that you need brackets around it like so: [User]