[ACCEPTED]-Incorrect syntax near the keyword 'User'-database
"User" is a reserved word in SQL Server, so 6 you have to use a delimited identifier to refer to your table. Try
SqlCommand command4 = new SqlCommand("SELECT * FROM [User]", conn);
instead... or 5 rename the table to something which isn't 4 reserved.
(I'd also strongly advise you to 3 keep the data access out of your UI code, dispose 2 of connections properly etc... but that's 1 a different matter.)
User is a built-in function in SQL Server. You 6 need to surround the name with square brackets:
[User]. This 5 goes for all table names and other user-defined 4 names that happen to collide with keywords, reserved 3 words or built-in names, so I suspect you 2 will need to write
[Order] as well, since
ORDER is an 1 SQL keyword.
More Related questions