から行を削除しても、データベースが更新されませんDataGridView
。キーを押してDelete
上の選択した行を削除してDataGridView
から、他の行に他の変更を加えたとします。
最後に、Save
ボタンを押してこれらすべての変更を保存します
これが私のコードです:
private bool SaveData(DataGridView dgv)
{
bool bDone = true;
DataTable dtVesselDataChanges;
SQLiteCommand DeleteCmd = new SQLiteCommand();
string sdeleteVesselCase = " public string SQL_DeleteVesselDataCase = "delete from vesseldata where plantid = @plantid and fileid=@fileid and vdid=@vdid";"
DeleteCmd.CommandText = sdeleteVesselCase;
dtVesselDataChanges = gdt.GetChanges();
if (dtVesselDataChanges.Rows.Count > 0 && dtVesselDataChanges != null)
{
for (int i = 0; i < dtVesselDataChanges.Rows.Count; i++)
{
if (dtVesselDataChanges.Rows[i].RowState == DataRowState.Deleted)
{
int rowindexPlant = Convert.ToInt32(gdt.Rows[i]["PlantId", DataRowVersion.Original]);
int rowindexFile = Convert.ToInt32(gdt.Rows[i]["FileId", DataRowVersion.Original]);
int rowindexVDID = Convert.ToInt32(gdt.Rows[i]["VDID", DataRowVersion.Original]);
DeleteCmd.Parameters.AddWithValue("@plantid", rowindexPlant);
DeleteCmd.Parameters.AddWithValue("@fileid", rowindexFile);
DeleteCmd.Parameters.AddWithValue("@VDID", rowindexVDID);
_DatabaseConnection.ExecuteQuery(DeleteCmd); ;
}
}
}
There is no error except DB is not updated