代码之家  ›  专栏  ›  技术社区  ›  Serhat Ozgel

如果Sql Compact允许多个连接,为什么会收到文件共享错误?

  •  6
  • Serhat Ozgel  · 技术社区  · 17 年前

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

    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]

    2 回复  |  直到 17 年前
        1
  •  9
  •   Serhat Ozgel    17 年前

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

    File Mode=Read Write
    

    解决了这个问题。

        2
  •  2
  •   Community Mohan Dere    9 年前

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

    According the MSDN said ,如否 File Mode 分配后,它将使用 Read Write

    Read Only db, this post said two parameters should be assigned 文件模式 Temp Path .