Thursday, March 15, 2012 6:33 AM
I am able to insert data in SQL Server Compact table successfully but whenever i clean and rebuild my solution, the data is washed out of database i.e. after cleaning and rebuilding my solution, i am not able to retrieve data from database.
Following is my code snippet:SqlCeConnection cn = new SqlCeConnection(@"Data Source=|DataDirectory|\applicationDB.sdf");
if (cn.State == ConnectionState.Closed)
string sql = "INSERT INTO userTable Values ('"+textBox1.Text+"' , '"+textBox2.Text+"')";
cmd = new SqlCeCommand(sql, cn);
lblResults.Text = "values inserted successfully!!";
catch (SqlCeException sqlexception)
MessageBox.Show(sqlexception.Message, "Oh Fudge.", MessageBoxButtons.OK, MessageBoxIcon.Error);
catch (Exception ex)
MessageBox.Show(ex.Message, "Fooey.", MessageBoxButtons.OK, MessageBoxIcon.Error);
could anybody please throw some light on my code?
Thanks in anticipation
Thursday, March 15, 2012 5:55 PMModeratorLook for a copy of your database in the bin/debug folder! See http://erikej.blogspot.com/2010/05/faq-why-does-my-changes-not-get-saved.html
Please mark as answer, if this was it. Visit my SQL Server Compact blog
Friday, March 16, 2012 8:42 AM
I agree with Erik. Have a look at the link posted by him.