Roman Nazarkin
Roman Nazarkin

Reputation: 2229

Data did't insert into SQL server compact table

I using a .sdf SQL server compact edition database and i want to insert data into it, but it didn't inserts!

My code:

string queryString = "INSERT INTO words(rus) VALUES(@wordp)";

SqlCeCommand cmd = new SqlCeCommand(queryString, conn);
cmd.Parameters.Add(new SqlCeParameter("@wordp", textBox1.Text));

cmd.ExecuteNonQuery();

cmd.Dispose();
conn.Close();

Connection opened correctly, and SELECT queries executes sucessfully. But after inserting data it's not inserts! I haven't any errors or warnings, and cmd.ExecuteNonQuery() return value 1 - query is executed correctly, but data not inserts!

In what could be the problem?

Upvotes: 0

Views: 2599

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1063005

This is usually simply an error of looking in the wrong file when debugging.

  • the original database is (generally) in your project directory
  • when you build, the project output including a copy of the database is copied to bin\debug or bin\release
  • during execution, you are editing the copy in bin\debug or bin\release
  • if you then stop and look at the version in your project directory, you won't see any changes, because you didn't edit that file (you edited the version in bin\debug or bin\release)
  • if you rebuild your project, you will often (depending on settings) overwrite the copy in bin\debug or bin\release, throwing away any changes

Upvotes: 4

Related Questions