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

前端 未结 2 651
野性不改
野性不改 2021-01-24 21:06

I started learning C# last week and I\'m now having trouble with an INSERT sql statement. I used the following code, then I tell you what happens.

private void A         


        
2条回答
  •  臣服心动
    2021-01-24 21:46

    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 ...
    

提交回复
热议问题