Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variable scope and try and catch
Message
De
17/09/2003 09:22:00
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00829818
Message ID:
00829834
Vues:
21
Dmitry,

Usually I will put all the code of a method in the try{}, even the stuff that does not need to be there and do nothing much other than return after the catch{} ... you don't have to put the try/catch only around the code that might cause errors. Don't know if this will help you or not since I haven't seen your code, but try it.

~~Bonnie


>After I added TRY and CATCH blocks to an ASP.NET page that worked, things started falling apart.
>
>First I enclosed the code that creates connection, opens connection and creates a data reader in the TRY { } block. The compiler complained that the Data Reader object and Connection object used after the CATCH {} block were undeclared.
>
>Then I declared the Data Reader and Connection objects before TRY but compiler now complaints that the objects are unassigned (when used after CATCH).
>
>It seems like C# compiler does not recognize anything that goes on inside TRY block.
>
>What am I misunderstanding? Please help.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform