I am doing a project in Visual Studio. I am using a local database (empty sql server compact version). I selected Dataset and created a table (Images). It has a primary auto-increment identifier column and an nvarchar ImagePath image column. I want to insert data into it, and here is my code.
SqlCeConnection con = new SqlCeConnection();
con.ConnectionString = yeniApplicationDatabase.Properties.Settings.Default.DatabaseEdaConnectionString;
con.Open();
using (SqlCeCommand com = new SqlCeCommand("INSERT INTO Images (ImagePath) VALUES ('book')", con))
{
com.ExecuteNonQuery();
}
I don't know why, but this one does not give any error, syntax (SQL) is fine. However, when I check the table data, it is still zero. That's what:
In the same run ,
I execute this code, then I execute another that selects * from the images ...
It shows a "book". But still, the table data is empty, and when I re-run it without insertion, only selecting from the images, it disappeared again. I really don't understand what is going on. Why can't I put anything in my database?
I also added con.Close (), but it still does not work.
source
share