Referring to question How do I share a SQL Server CE database file (.sdf) for multiple processes?
According MSDN, SQL CE allows 256 concurrent connections to single database.
But even on the SAME machine, I facing sharing violation error when I open the same database BUT with 2 different process (a.exe & b.exe, code is the same). What seems to be the problem here?
I was using connection string
SqlCeConnection("Data Source=d:\test.sdf;Encrypt Database=True;Password=test;File Mode=read write;")
This is not the answer you want to hear, but you should never attempt to open an SQL CE file from multiple processes. Yeah, I know, SQL CE 4.0 allows multiple writers, and you think you'll never have multiple writers writing to the same record, but this is like thinking it's safe to juggle flaming chainsaws so long as you wear a blindfold.
SQL CE modifies changed bytes inside the live data file. You cannot reliably do this from multiple processes. You think you can, but you can't. Read the accepted answer to the question you quoted; use a service-oriented database like SQL Express.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With