0

I've created a SQL Compact Local DB in my app, added a Dataset for the tables that I created, and want to insert data into the table now.

When I execute the Insert TableAdapter method it seems to insert the data into the table, because when I Fill the DataTable after the insert there is 1 record there, however when I restart the app there is no data anymore.

Even after the insert when I query the table through Server Explorer, still no data. Do I miss something important, because I cannot seem to find that I shoud do anything else.

On App Startup

private void MainForm_Load(object sender, EventArgs e)
{
        personsTA.Fill(ds.Persons);   //ds.Persons.Count is 0;
        MyInsert();
}

private void MyInsert()
{
   personsTA.Insert(<all the params>);  //This returns 1
   //ds.Persons.Count still returns 0
   personsTA.Fill(ds.Persons);         //ds.Persons.Count now returns 1;
}

But when I restart the app, the Fill returns 0 again. Do I have to commit the data somehow or something? Is there a setting I need to change?

Thanks

Jaques
  • 2,215
  • 1
  • 18
  • 35
  • What does your connection string look like? Wild guess: when you test your application, a copy of the sdf is made and put into the application directory (bin\Release or bin\Debug for example). You make changes there, but with the server explorer you are still looking at the original (empty) sdf. – Corak Feb 26 '15 at 09:44
  • Yes I do, but it is set to Copy only if newer. I've changed it to Don't copy now, and edited the app.config and pointed to the db in the solution directory. Post an answer, and I will give you credit :) Thanks – Jaques Feb 26 '15 at 09:55
  • View solution in this [this](http://stackoverflow.com/questions/12758283/changes-are-not-saved-in-sql-server-compact-3-5-database) thread. – Filipe Baumeister Apr 10 '17 at 17:12

0 Answers0