SQL Server Compact edition 3.5数据库访问被拒绝

本文关键字:数据库 访问 拒绝 Server Compact edition SQL | 更新日期: 2023-09-27 17:52:54

我使用Microsoft SQL Server Compact Edition 3.5用c#开发了一个桌面应用程序。

当我从解决方案文件夹(bin'releasedebug)运行.exe文件时,它工作正常,但当我试图通过创建其设置来部署它时,它显示未处理的异常:

您没有访问CustomersDB的权限。自卫队文件。

注意没有路径错误,它是正确的。

string lokasifile = Environment.CurrentDirectory + "''CustomersDB.sdf";
string stringkoneksi = "Data Source = '"" + lokasifile + "'"";
SqlCeConnection koneksi = new SqlCeConnection(stringkoneksi);
koneksi.Open();

SQL Server Compact edition 3.5数据库访问被拒绝

SecurityException 

这只是呼叫者没有适当的权限。环境。CurrentDirectory地产

try
{
     //Call Path here you will get to what the exactly error is
}
catch (Exception ex)
{
     if (ex is DirectoryNotFoundException|| ex is IOException|| ex is SecurityException)
     {
          //Your handling here
     }
     else
     {
          throw;
     }
}