I have my strings in a String array, my Data in a datatable.
What I have to do is, select a single row using datatable.select(string) method and delete it from the datatable.
this is what I am doing, and its working fine many times but its returning an error if I change the array frequently. I have checked the datarows in the datatable and also the matching string. they are there as they are supposed to be. But some times it still returns null. But when I checkback, the data is exactly as I want it to be.
for (int k = 0; k < p; k++)
{
string tempMapString = "ID =" + IDArray[k];
try
{
DataRow[] rows = myTable_2_ForCBL.Select(tempMapString);
//MessageBox.Show(IDArray[k].ToString(), "ID Array Element");
MessageBox.Show(tempMapString + " " + rows.Length.ToString(), "No of Rows mapped are:");
if (rows.Length > 0)
{
foreach (DataRow row in rows)
{
row.Delete();
}
}
}
catch (Exception err2)
{
MessageBox.Show(err2.Message);
}
}
let me know if I am missing something. There columns in the datatable are "ID" and "LocationName". ID is like the primary key and is the valuemember of the checkedbox list.