question

masudHosseinian-0862 avatar image
0 Votes"
masudHosseinian-0862 asked Cathyji-msft answered

SqlCE on Shared network folder locks the sdf file

I have a .net application that uses SqlCE. I can easily open the database and then go to the folder where the sdf file is located and make a copy of it(We do that to create backups when user requests it). When I try the same workflow using a shared network folder, i get shared file access error saying another process is using that file. Does sqlCE open the sdf file differently when the file is on a network folder?

sql-server-general
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Are you copying the file manually?

0 Votes 0 ·

yes, I use File.Copy in C#. It has worked for the last 15 years. Now we are setting up some shared network folder and it looks like SqlCe is locking the file exclusively. Nothing changed as closing the connections and other stuff goes. Just using the sdf file on a network folder

0 Votes 0 ·
Viorel-1 avatar image Viorel-1 masudHosseinian-0862 ·

Maybe it happened because of termination of lifecycle today: https://docs.microsoft.com/en-us/lifecycle/products/microsoft-sql-server-compact-40?

0 Votes 0 ·

1 Answer

Cathyji-msft avatar image
0 Votes"
Cathyji-msft answered

Hi @masudHosseinian-0862,

Although SQL Server Compact Edition supports concurrent database connections from multiple threads and multiple processes, concurrent access is not supported when the database file is located on a network drive. SQL Server Compact Edition prevents it by automatically acquiring an exclusive lock on the database file when a connection is made to the database file via a network share.


If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.