簡體   English   中英

SQL Server Compact 3.5版數據庫訪問被拒絕

[英]SQL Server Compact edition 3.5 database acess is denied

我使用Microsoft SQL Server Compact Edition 3.5在C#中開發了一個桌面應用程序。

當我從解決方案文件夾( bin\\releasedebug )運行.exe文件時它工作正常,但當我嘗試通過創建它的設置來部署它時,它顯示未處理的異常:

您無權訪問CustomersDB.sdf文件。

請注意,沒有路徑錯誤,它是正確的。

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

這只不過是來電者沒有相應的許可。 Environment.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;
     }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM