Im trying to insert data to my compact database, I got this error:
There was an error parsing the query. [ Token line number = 1,Token line offset = 1,Token in error = USE ]
And here is my code, mostly found online:
SqlCeConnection conn = new SqlCeConnection(@"Data Source=|DataDirectory|\CompactDatabase.sdf");
conn.Open();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "USE Movie INSERT INTO Movie(title, ean) VALUES(?,?)";
cmd.Parameters.AddWithValue("@title", title);
cmd.Parameters.AddWithValue("@ean", ean);
cmd.Prepare();
cmd.ExecuteNonQuery();
Anyone figure out the problem?
Just throw away
USEclause and execute this query instead:USEis a context switching clause between databases in T-SQL, that is not applicable here.