I have a problem with inserting into a MSSQL CE database,
locCon.Open();
SqlCeCommand locCmd = locCon.CreateCommand();
locCmd.CommandText = "INSERT INTO user (ID,FName,LName,Email) VALUES('"+this.id+"','"+this.fName+"', '"+this.lName+"','"+this.email+"')";
locCmd.ExecuteNonQuery();
When running this I get
There was an error parsing the query. [Token line number = 1, Token line offset = 13, Token in error = user]
Now i cant see anything wrong with the query although this is the firsr time ive used MS SQL of examples ive seen the syntax for mysql and msssql are identical well for inserts anyway. Is there soemthing obviously wrong with this?
Thanks
I think “user” is a reserved word in the database. Try replacing this:
with this:
(I think it’ square brackets for MSSQL CE, since it is for other MSSQL engines.)
The square brackets basically tell the query engine, “This is an identifier for an object in the database.” They’re commonly used to wrap the names of database objects which contain spaces, since those otherwise wouldn’t parse correctly. But it’s also useful for objects which are reserved words.