The error is:
An unhandled exception of type \'System.Data.SqlClient.SqlException\' occurred in System.Data.dll
Additional information: Incorrec
"User" is a reserved word in SQL Server, so you have to use a delimited identifier to refer to your table. Try
SqlCommand command4 = new SqlCommand("SELECT * FROM [User]", conn);
instead... or rename the table to something which isn't reserved.
(I'd also strongly advise you to keep the data access out of your UI code, dispose of connections properly etc... but that's a different matter.)
User
is a built-in function in SQL Server. You need to surround the name with square brackets: [User]
. This goes for all table names and other user-defined names that happen to collide with keywords, reserved words or built-in names, so I suspect you will need to write [Order]
as well, since ORDER
is an SQL keyword.