How do I get changes to be committed to the .sdf
?
If the app crashes then all changes to the database are left in a temp file and do not get committed to the database .sdf
.
Do I need to close and reopen the connection, or is there a setting or better way?
My app is designed to work with either SQL Server CE or "normal" SQL Server, so it uses ProviderFactory
to get connections. When using SQL Server Express, the connection is opened and closed with every transaction, and all changes are committed immediately.
But with SQL Server CE, on a few machines, there is a 30-second delay while SQL Server CE is opened (the cause seems to be access-permissions on a .NET encryption file. SEE: SQL Server CE extremely slow on some computers)
So, with SQL Server CE, I leave the connection open for the whole duration app, but if it crashes or I stop it with the debugger, then the DB changes don't get saved.
Database file is in ApplicationData
area.
I'm using SQL Server CE 4.0, private deployment.
Thanks for your help!