Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variable scope and try and catch
Message
 
 
À
17/09/2003 17:02:29
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00829818
Message ID:
00830113
Vues:
30
Bonnie,
Thank you for pointing it to me. I didn't understand his message correctly (habit of speed reading <g>)


>Dmitry,
>
>Plamen already got it, but you may have missed it. If you intialize your variables with null prior to the try/catch, it should still work.
>
>SqlCommand sc = null;
>DataReader dr = null;
>// etc.
>try
>{
>    sc = new SqlCommand();
>    // and all the rest of the stuff
>}
>catch (SqlException ex)
>{
>}
>
>
>~~Bonnie
>
>>>>>
>>>Don't want to answer for Plamen, but you didn't get it right. You have to initialize all variables prior to try/finally block.
>>
>>That's not my understanding. The idea of TRY is to try to initialize things to see if they work and if they don't catch them. I know I have to declare them prior to TRY but it is different from initializing. Perhaps Plamen or Bonnie will correct me or you :-)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform