【问题标题】:Why do I receive file share error if Sql Compact allows multiple connections?如果 Sql Compact 允许多个连接,为什么我会收到文件共享错误?
【发布时间】:2009-01-09 12:28:39
【问题描述】:

Here,据说Sql Server Compact最多允许256个连接。

但是当我尝试打开 2 个连接时,我收到文件共享错误。我该如何解决这个问题?

SqlCeConnection c1 = new SqlCeConnection("Data Source=testDB.sdf;Encrypt Database=True;Password=test;File Mode=shared read;Persist Security Info=False;");
SqlCeConnection c2 = new SqlCeConnection("Data Source=testDB.sdf;Encrypt Database=True;Password=test;File Mode=shared read;Persist Security Info=False;");
c1.Open();
c2.Open(); // throws SqlCeException
c1.Close();
c2.Close();

存在文件共享冲突。不同的进程可能正在使用该文件。 [testDB.sdf]

【问题讨论】:

    标签: sql-server-ce database-connection


    【解决方案1】:

    这是一个连接字符串问题。

    File Mode=Read Write
    

    解决了问题。

    【讨论】:

    • 我也遇到了同样的问题。真是愚蠢的错误...感谢您纠正我。
    • 我在一个有并发用户的小型网站上使用 SQL compact 4.0 时遇到了同样的错误。这个建议没有解决我的问题。
    【解决方案2】:

    在调查这个问题时,我找到了一些资源和这篇文章。也许有人会需要它,所以我把找到的东西留在这里。

    According the MSDN said,如果没有分配File Mode,默认使用Read Write

    并且,如果需要打开一个Read Only db,this post said two parameters should be assigned。一个是File Mode,一个是Temp Path

    【讨论】:

      猜你喜欢
      • 2014-01-25
      • 1970-01-01
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多