【发布时间】: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