私は更新クエリになり、次のコードを、持っている:ExecuteScalar
は、DB接続の方法であるSQLiteデータベースは更新後C#でロックされていますか?
public void update(ClientResponse client)
{
db.ExecuteScalar("UPDATE PacientsOrder SET status = '"+client.status+"' WHERE pacient_id = '" + client.pacient_id + "' AND kind_work = '" + client.kind_work + "'"); // 222 Line
db.ExecuteScalar("UPDATE Transactions SET http_code = '" + client.http_code+ "' WHERE pacient_id = '" + client.pacient_id+"'");
}
を:私は上記のクエリを実行しようとすると
public string ExecuteScalar(string sql)
{
SQLiteConnection cnn = new SQLiteConnection(dbConnection); // 119 line
cnn.Open();
SQLiteCommand mycommand = new SQLiteCommand(cnn);
mycommand.CommandText = sql;
object value = mycommand.ExecuteScalar();
cnn.Close();
if (value != null)
{
return value.ToString();
}
return "";
}
は、エラーが表示されます。
System.Data.SQLite.SQLiteException (0x80004005): database is locked
database is locked
в System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
в System.Data.SQLite.SQLiteDataReader.NextResult()
в System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
в System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
в System.Data.SQLite.SQLiteCommand.ExecuteScalar(CommandBehavior behavior)
в System.Data.SQLite.SQLiteCommand.ExecuteScalar()
в SQLiteDatabase.ExecuteScalar(String sql) в D:\Projects\Library\SQLiteDatabase.cs:строка 119
Pacients.update(ClientResponse client) в D:\Projects\c-tests-u Controllers\Pacients\Pacients.cs:строка 222
このエラーの原因を理解できません。
Thissi俺のDeleteメソッド:
public bool Delete(String tableName, String where)
{
Boolean returnCode = true;
try
{
this.ExecuteNonQuery(String.Format("delete from {0} where {1};", tableName, where));
}
catch (Exception fail)
{
MessageBox.Show(fail.Message);
returnCode = false;
}
return returnCode;
}
更新SQLは、メソッドの削除:SQLiteCommandよう
public bool Delete(String tableName, String where)
{
string sql = String.Format("delete from {0} where {1};", tableName, where);
using (SQLiteConnection cnn = new SQLiteConnection(dbConnection))
using (SQLiteCommand mycommand = new SQLiteCommand(sql, cnn))
{
cnn.Open();
object value = mycommand.ExecuteNonQuery();
return (value != null) ? value.ToString() : "";
}
}
おそらく、あなたの 'mycommand'を削除しないことが理由です。 – Evk
...あなたが最後に尋ねたときに説明したように – Plutonix