
I have a problem with the code below.
I have a table that has a column called REGISTRO. Some times i have two or more lines with the same value in the column REGISTRO.
I want to remove all lines in the table with an specific value. For example all lines with REGISTRO value equals MNRJ02.
The program executes all of the commands and dont show me any error.
In the end when I open the table to verify the alterations, the lines had not been excluded and still they are in the table.
If somebody will be able to help me
Thanks
My 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");
MessageBox.Show ("Registro "+registroSgc+" excluÃdo com Sucesso",
"HARPIA - REGISTRO EXCLUÃDO",MessageBoxButtons.OK, MessageBoxIcon.Information);