I am simply trying to add a single row in the database but I keep getting an exception. I created a local database and added a single table: users. It consists of two columns: "id" and "name". I only made the id primary key (not auto-increment or anything else).
When I run the following code:
string execPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
string dbfile = execPath + @"\LocalDatabase.sdf";
SqlCeConnection conn = new SqlCeConnection("datasource=" + dbfile);
conn.Open();
string command = "INSERT INTO users VALUES('1','pek')";
Debug.WriteLine(command);
SqlCeCommand comm = conn.CreateCommand();
comm.CommandText = command;
comm.ExecuteNonQuery();
I get the following Exception at "comm.ExecuteNonQuery();":
SqlCeException was unhandled
The column cannot be modified. [ Column name = id ]
What's with the "modified" part?