I have the below code :
if (reader.HasRows)
{
while (reader.Read())
{
DataRow searchedDR = ds.Tables[dr["name"].ToString()].Rows.Find(reader["ID"].ToString());
if (searchedDR != null)
ds.Tables[dr["name"].ToString()].Rows.Remove(searchedDR);
}
}
When this block of code done successfully the data reader (reader) become empty?
What is the reason?
I need to work with this reader afterward. What is the solution?
A data-reader is a hose of data. It becomes “empty” (or a better analogy: runs dry) when you consume all the data it is reading.
It is not a storage device (it isn’t a bucket). If you want the data afterwards, store it somewhere – a
DataTableor a class model, for example.