Re: A question about closing the SqlDataReader
- From: J L <john@xxxxxxxxxxxxx>
- Date: Thu, 31 Mar 2005 08:35:28 -0800
I am a newbie and using VB.Net. I had understood that Using was
equivalent to Imports. I know read in the online help that it also can
be used to define scope, as you are indicating here. Is there an
equivalent in VB.Net to this construct?
TIA
John
On Wed, 30 Mar 2005 21:37:19 +0200, "Miha Markic [MVP C#]" <miha at
rthand com> wrote:
>Yes, it is necessary to close it.
>More slick way would be (note that you don't need explicit Close call - it
>is handled through implicit Dispose):
>
>using (SqlDataReader reader = cmd.ExecuteReader())
>{
>if (reader.Read())
>> {
>> // do something here
>> }
>> else
>> {
>> Response.Redirect("to_some_other_page.aspx");
>> }
>}
.
- References:
- Prev by Date: Re: ConnectionRead (WrapperRead()) timeout
- Next by Date: Re: Problems inserting data into Access database
- Previous by thread: A question about closing the SqlDataReader
- Next by thread: Re: A question about closing the SqlDataReader
- Index(es):
Relevant Pages
|