I'm trying to put anything into my DB. Message Box is showing that I did put 1 row to DB, but when I check it - nothing happened.
Anybody know the cure?
SqlCeConnection cn = new SqlCeConnection(@"Data Source = Database1.sdf");
try
{
cn.Open();
}
catch (SqlCeException ex)
{
MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.ExitThread();
}
SqlCeCommand cm = new SqlCeCommand("INSERT INTO Sentences (Sentence) VALUES ('Sentence')", cn);
//cm.Parameters.AddWithValue("@Sentence", "Any sentence");
try
{
int rowsAffected = cm.ExecuteNonQuery();
MessageBox.Show((rowsAffected.ToString()));
}
catch (Exception)
{
MessageBox.Show("Insertion Failed");
}
cn.Close();