Exception Handling and Loops

  • Thread starter Thread starter Shikari Shambu
  • Start date Start date
S

Shikari Shambu

Hi,
I have a while loop where for each value I execute a database query. I
have a situation where one of these queries abort due to bad data. I want
the application to continue processing the loop for other values.

I have tired what I thought would do this but it still aborts the
application on error.

I have a Manager class that has the while loop that calls a Data class that
fromulates the parameters and the the right stored proc and that calls the
MS. Data Access application block to execute the query

The block of code in the manager class looks like this
SqlDataReader drIDs = GetInformation();

while (drIDs.Read())
{
int iId = drIDs.GetInt32(0);
try
{
GenerateReport(iId);
}
catch (Exception e)
{
throw;
continue;
}
}

The error I get is .Net SQL Client Data Provider. Subquery returned more
than one value. How do I skip the error and continue processing the loop for
other values.

TIA
 
I removed the throw. But, I still get an exception and it breaks. The
exception I get is an unhandled exception .System.data.dll.
 
Back
Top