Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > question about using connection

Reply
Thread Tools

question about using connection

 
 
Eric
Guest
Posts: n/a
 
      03-07-2009
Hi,

i use this for a database connection:

Using mConnection As New SqlConnection(param.ConnectionString)
mConnection.Open()
sql = "insert ...."
comd = New SqlCommand(sql, mConnection)
comd.ExecuteNonQuery()
End Using

My question is: do i need to close the connection with: mConnection.Close()
or does the End Using do itself?

thanks
Eric


 
Reply With Quote
 
 
 
 
Andy B.
Guest
Posts: n/a
 
      03-07-2009
The end using statement closes it. If you don't use the using statement you
would have to close it yourself.
"Eric" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> i use this for a database connection:
>
> Using mConnection As New SqlConnection(param.ConnectionString)
> mConnection.Open()
> sql = "insert ...."
> comd = New SqlCommand(sql, mConnection)
> comd.ExecuteNonQuery()
> End Using
>
> My question is: do i need to close the connection with:
> mConnection.Close() or does the End Using do itself?
>
> thanks
> Eric
>
>



 
Reply With Quote
 
 
 
 
Eric
Guest
Posts: n/a
 
      03-07-2009
thanks

"Andy B." <(E-Mail Removed)> schreef in bericht
news:%(E-Mail Removed)...
> The end using statement closes it. If you don't use the using statement
> you would have to close it yourself.
> "Eric" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi,
>>
>> i use this for a database connection:
>>
>> Using mConnection As New SqlConnection(param.ConnectionString)
>> mConnection.Open()
>> sql = "insert ...."
>> comd = New SqlCommand(sql, mConnection)
>> comd.ExecuteNonQuery()
>> End Using
>>
>> My question is: do i need to close the connection with:
>> mConnection.Close() or does the End Using do itself?
>>
>> thanks
>> Eric
>>
>>

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      03-08-2009
Find here more details:

http://stackoverflow.com/questions/3...sql-connection


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


"Eric" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> thanks
>
> "Andy B." <(E-Mail Removed)> schreef in bericht
> news:%(E-Mail Removed)...
>> The end using statement closes it. If you don't use the using statement
>> you would have to close it yourself.
>> "Eric" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi,
>>>
>>> i use this for a database connection:
>>>
>>> Using mConnection As New SqlConnection(param.ConnectionString)
>>> mConnection.Open()
>>> sql = "insert ...."
>>> comd = New SqlCommand(sql, mConnection)
>>> comd.ExecuteNonQuery()
>>> End Using
>>>
>>> My question is: do i need to close the connection with:
>>> mConnection.Close() or does the End Using do itself?
>>>
>>> thanks
>>> Eric
>>>
>>>

>>
>>

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
No "Wireless Network Connection" available in network connection =?Utf-8?B?am9raW5kYTE=?= Wireless Networking 7 10-16-2012 07:32 AM
Using Connection Class VS Connection Module Dave Johnson ASP .Net 5 12-11-2005 01:28 PM
ICS works with wired connection, fails with wireless connection Rich Wireless Networking 0 11-16-2005 06:48 PM
Wireless Connection drops / PS2 connection Steve Wireless Networking 1 07-27-2005 01:27 PM
Not seeing Wireless Connection in Network Connection =?Utf-8?B?bW90b21hbm1hdHQ=?= Wireless Networking 4 03-05-2005 04:39 AM



Advertisments