
I want to use the code below to delete rows in a table using the DATASET in conjunction with a DataAdapter.
I do not know what this wrong one, the code compels error-free and when this is executed it not eliminating the lines of my table.
The code below:
thisAdapter = new OleDbDataAdapter ("SELECT * FROM lig_det ORDER BY registro", dbBanco.thisConnection);
thisBuilder = new OleDbCommandBuilder (thisAdapter);
thisDataSet = new DataSet ();
thisAdapter.Fill (thisDataSet, "lig_det");
//percorrendo toda a tabela LIG_DET para achar os registros que devem
//ser eliminados
for (int i = 0; i < thisDataSet.Tables ["lig_det"].Rows.Count; i++)
{
if (registroSgc == thisDataSet.Tables ["lig_det"].Rows [i]["registro"].ToString ())
{
thisDataSet.Tables ["lig_det"].Rows [i].Delete ();
MessageBox.Show ("Estado do registro na tabela " +thisDataSet.Tables ["lig_det"].Rows [i].RowState.ToString ());
}//final do if
}//final do FOR
thisDataSet.Tables ["lig_det"].AcceptChanges ();
thisAdapter.Update (thisDataSet, "lig_det");