【问题标题】:.NET Core SQLite 'database is locked' only on Linux.NET Core SQLite '数据库已锁定'仅在 Linux 上
【发布时间】:2019-02-18 21:28:05
【问题描述】:

我有一个问题,我有一个小程序可以检索 CSV 文件并将其转换为 Sqlite 数据库。在 Windows 上没问题,它工作得很好。但是,在 Linux 上,我收到一条错误消息:

string connectionString = "Data Source=" + PathFile + targetFile;
using (SqliteConnection m_dbConnection = new SqliteConnection(connectionString))
{
    m_dbConnection.Open();
    // Requêtes de création des tables
    string sql = String.Empty;
    sql = String.Concat(sql, "CREATE TABLE TARGETS (idTarget NUMERIC, customerId NUMERIC, numberCard TEXT, mail TEXT, mobile TEXT, bat NUMERIC);");
    sql = String.Concat(sql, "CREATE TABLE COLUMNS (idColumn  NUMERIC, name TEXT, isVariable NUMERIC);");
    sql = String.Concat(sql, "CREATE TABLE ROW (idTarget  NUMERIC, idColumn TEXT, value TEXT);");
    // Execution des requêtes de création
    using (SqliteCommand command = new SqliteCommand(sql, m_dbConnection))
    {
         countRow += command.ExecuteNonQuery(); // <===== /!\ Exception here
    }
}

Unhandled Exception: Microsoft.Data.Sqlite.SqliteException: SQLite Error 5: 'database is locked'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery() at Mailing.Service.ServiceFile.ConvertCSVToSQLite(String sourceFile, String targetFile) at Mailing.Service.ServiceFile.UploadFile(Byte[] byteFile, String filename, TypeCanal canal, Int32 idMailing, Boolean async) at MailingAutomator.Program.Main(String[] args) in Program.cs:line 64

对于 Microsoft.Data.Sqlite,Linux 和 Windows 之间有什么不同吗? 与在 Linux 上我在已安装的 NAS 上读写的事实有关吗?访问问题? sqlite 数据库已创建但为空。

.NET Core 2.2 Microsoft.Data.Sqlite Ubuntu 16.04

编辑:一些新闻: 当我在其他 ubuntu 服务器上使用 samba 共享时,它可以工作 但是在其他 Windows 共享上,我再次收到此错误...日志文件出现并消失了好几次。 我不明白,sqlite 文件已创建但为空

【问题讨论】:

    标签: c# linux sqlite .net-core ubuntu-16.04


    【解决方案1】:

    我的代码没有问题。 我通过在我的 mount 命令中添加“nobrl”解决了我的问题,它的工作原理。

    nobrl : Do not send byte range lock requests to the server. This is necessary for certain applications that break with cifs style mandatory byte range locks (and most cifs servers do not yet support requesting advisory byte range locks).
    

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 2020-01-07
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      • 2020-12-02
      • 2012-08-12
      • 2011-08-05
      相关资源
      最近更新 更多