Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

Exception Handling and Loops

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shikari Shambu - 20 May 2004 18:29 GMT
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
AlexS - 20 May 2004 18:53 GMT
Hi, Shikari

remove throw statement from catch clause and take a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conHandlingThrowingExceptions.asp


HTH
Alex

> Hi,
>     I have a while loop where for each value I execute a database query. I
[quoted text clipped - 30 lines]
>
> TIA
Shikari Shambu - 20 May 2004 19:33 GMT
I removed the throw. But, I still get an exception and it breaks. The
exception I get is an unhandled exception .System.data.dll.

> Hi, Shikari
>
> remove throw statement from catch clause and take a look at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conHandlingThrowingExceptions.asp


> HTH
> Alex
[quoted text clipped - 35 lines]
> >
> > TIA
David Levine - 21 May 2004 01:49 GMT
Did you try putting an try-catch block around the call to Read()?

> I removed the throw. But, I still get an exception and it breaks. The
> exception I get is an unhandled exception .System.data.dll.
>
> > Hi, Shikari
> >
> > remove throw statement from catch clause and take a look at

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conHandlingThrowingExceptions.asp


> > HTH
> > Alex
[quoted text clipped - 38 lines]
> > >
> > > TIA

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.