[英]Database table is locked (C# , Sqlite3)
SQLiteCommand sqlite_cmd_show;
SQLiteConnection sqlite_conn;
SQLiteDataReader sqlite_datareader;
sqlite_cmd_show = sqlite_conn.CreateCommand();
sqlite_cmd_show.CommandText = "SELECT * FROM stock WHERE item_barcode = @barcode and serial_data != '' and serial_data > @serial";
sqlite_cmd_show.Parameters.Add("@barcode", System.Data.SqlDbType.Int);
sqlite_cmd_show.Parameters.Add("@serial", System.Data.SqlDbType.Int);
for (int count = 0; count < DataGItem.Rows.Count; count++)
{
isExist = false;
sqlite_cmd_show.Parameters["@barcode"].Value = (String)DataGItem.Rows[count].Cells[1].Value;
sqlite_cmd_show.Parameters["@serial"].Value = (String)DataGItem.Rows[count].Cells[6].Value;
sqlite_datareader = sqlite_cmd_show.ExecuteReader();
while (sqlite_datareader.Read())
{
isExist = true;
break;
}
if (isExist)
{
continue;
}
sqlite_cmd = sqlite_conn.CreateCommand();
sqlite_cmd.CommandText = "Insert into stock ( stock_id, item_barcode ) VALUES ("+ stock_id +",'" + txtDocNo.Text + "')";
sqlite_cmd.ExecuteNonQuery();
這是我的示例代碼,其錯誤出現在最后一行“ sqlite_cmd.ExecuteNonQuery();”。
錯誤是
所以,我嘗試做很多事情,但是沒有用
請幫忙,
在插入語句之前關閉連接
sqlite_conn.Close()
然后打開一個新的
sqlite_conn.Open()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.