I have a database named DbTest
and a table named user
. It is throwing an exception in the line cmd.ExecuteReader();
The exception message says:
There is an error parsing the query
What should I do?
conString = Properties.Settings.Default.DbTestConnectionString;
con = new SqlCeConnection(conString);
con.Open();
cmd = new SqlCeCommand("SELECT * FROM user", con);
rdr = cmd.ExecuteReader();
The error message is quite vague if you ask me. The problem lies in the use of the name user
for your table. user
is preserved keyword and it can't be used without proper escaping.
Escape user
with brackets:
SELECT * FROM [user]