PC Review


Reply
Thread Tools Rate Thread

Context Connection & Using

 
 
Scott M.
Guest
Posts: n/a
 
      24th Nov 2007
When working with the SQL CLR, should I be using "using" when referring to
the "context connection"?


 
Reply With Quote
 
 
 
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      26th Nov 2007
Hello Scott,

According to your description, you want to know if we should wrap the
connection with "using" blocks in SQL CLR, correct? If I misunderstood
anything here, please don't hesitate to correct me.

In my opinion, working with the Using Block is recommended, but no
necessary.
Working with using block guarantees disposal of the resources, no matter
how we exit the block. However, if you make sure you will close the
connection by yourself, it is not necessary to put it into Using Block
again.

Hope this helps. Please feel free to update there again, if there is
anything unclear. We are glad to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      26th Nov 2007
Hi Wen,

Thanks for you response.

I am aware of what using does and agree that if you manage the connection
correctly, its use is not needed. My question is a bit more involved than
this though. When using the context connection in SQL CLR, should Using be
used (or if I am managing the connection myself, should I be closing and
disposing it)?

The point being that the context connection represents the connection that
that calling code is using. If I were to close and dispose of that
connection in the SQL CLR code, then wouldn't that have ramifications on the
caller's ability to continue to use the connection if desired?

-Scott

"WenYuan Wang [MSFT]" <v-(E-Mail Removed)> wrote in message
news:%23tGuwK%(E-Mail Removed)...
> Hello Scott,
>
> According to your description, you want to know if we should wrap the
> connection with "using" blocks in SQL CLR, correct? If I misunderstood
> anything here, please don't hesitate to correct me.
>
> In my opinion, working with the Using Block is recommended, but no
> necessary.
> Working with using block guarantees disposal of the resources, no matter
> how we exit the block. However, if you make sure you will close the
> connection by yourself, it is not necessary to put it into Using Block
> again.
>
> Hope this helps. Please feel free to update there again, if there is
> anything unclear. We are glad to assist you.
>
> Have a great day,
> Best regards,
>
> Wen Yuan
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>


 
Reply With Quote
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      27th Nov 2007
Hello Scott,

It sound like your main concern is if closing/disposing the connection in
SQLCLR code will effect on the caller's ability to continue to use the
connection, correct? Please don't hesitate to correct me, if I
misunderstood anything again.

SQL CLR creates new connection with the same context of caller's connection
in his code. It doesn't use caller's connection. They are not the same
connection. Thereby, (as far as I know), whatever we do on the context
connection, this will not effect on the caller's connection.

Hope this helps. Please feel free to update here again, if there is
anything unclear. We are glad to assist you.
Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
William Vaughn
Guest
Posts: n/a
 
      30th Nov 2007
My question (again) is why are you using the Context Connection in the first
place and not a TSQL routine to manage rowsets?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Scott M." <(E-Mail Removed)> wrote in message
news:%23w$(E-Mail Removed)...
> When working with the SQL CLR, should I be using "using" when referring to
> the "context connection"?
>


 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      30th Nov 2007
I'm asking the question purely for an understanding of how to do it. I
understand when to use T-SQL vs. CLR code.


"William Vaughn" <(E-Mail Removed)> wrote in message
news:5FD408CC-4E6B-4071-8083-(E-Mail Removed)...
> My question (again) is why are you using the Context Connection in the
> first place and not a TSQL routine to manage rowsets?
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant, Dad, Grandpa
> Microsoft MVP
> INETA Speaker
> www.betav.com
> www.betav.com/blog/billva
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
> Visit www.hitchhikerguides.net to get more information on my latest book:
> Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
> and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
> -----------------------------------------------------------------------------------------------------------------------
>
> "Scott M." <(E-Mail Removed)> wrote in message
> news:%23w$(E-Mail Removed)...
>> When working with the SQL CLR, should I be using "using" when referring
>> to the "context connection"?
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Strange Context Error: Context 0x197ee0 is disconnected in VS 2005 =?Utf-8?B?U3VuU21pbGU=?= Microsoft ASP .NET 0 10th Jan 2006 03:59 PM
Problem in Context connection of CLR Trigger None Microsoft C# .NET 1 2nd Aug 2005 07:34 PM
Problem in Context connection of CLR Trigger None Microsoft ADO .NET 1 2nd Aug 2005 03:48 PM
Problem in Context connection of CLR Trigger None Microsoft Dot NET Framework 1 2nd Aug 2005 11:22 AM
Context menus and treeviews, suggestions for a NODE sensitive context menu Eric Newton Microsoft Dot NET Framework Forms 4 13th Jan 2004 09:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:26 PM.