<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Sushil's WebLog</title><link>http://blogs.msdn.com/sushilc/default.aspx</link><description>Random ADO.Net discussion</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Time to resurrect my blog...</title><link>http://blogs.msdn.com/sushilc/archive/2009/06/08/time-to-resurrect-my-blog.aspx</link><pubDate>Mon, 08 Jun 2009 20:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9708583</guid><dc:creator>sushilc</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/9708583.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=9708583</wfw:commentRss><description>&lt;P&gt;Its me again after 4 long year. I have decided to start blogging agian. From the last time I wrote in 2005, there have been multitude of things I have been working. I was working on JDBC driver for SQL Server in 2005-06 and then moved to Entity Framework, which had its first release as part of .Net Framework 3.5 SP1. Currently, I am working on Entity Framework 4.0 and LINQ to SQL. With the public release of Visual Studio 2010 Beta1 and Entity Framework 4.0 Beta1, I think it is an opportune time for me&amp;nbsp;to start with my ramblings about Entity Framework, in general. &lt;/P&gt;
&lt;P&gt;Hope you will find something useful here in the future,&lt;/P&gt;
&lt;P&gt;Sushil.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9708583" width="1" height="1"&gt;</description></item><item><title>SQL Server 2005 and Visual Studio 2005 RTM!</title><link>http://blogs.msdn.com/sushilc/archive/2005/10/28/486348.aspx</link><pubDate>Fri, 28 Oct 2005 22:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:486348</guid><dc:creator>sushilc</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/486348.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=486348</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Yes, we have done it! SQL Server 2005 and Visual Studio 2005 are now released to manufacturing. What this means that we are done with both the products, you can even download the official bits if you have MSDN subscription. More information can be found at &lt;A href="http://msdn.microsoft.com/subscriptions/"&gt;http://msdn.microsoft.com/subscriptions/&lt;/A&gt; . The official launch of these products will happen on Nov. 7 2005 in San Francisco. You can find more information about the Launch at &lt;A href="http://msdn.microsoft.com/Launch2005/"&gt;http://msdn.microsoft.com/Launch2005/&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Looking forward to your feedback and comments.&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=486348" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Misc/default.aspx">Misc</category></item><item><title>SqlDependency changes for RTM</title><link>http://blogs.msdn.com/sushilc/archive/2005/09/27/474454.aspx</link><pubDate>Tue, 27 Sep 2005 19:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:474454</guid><dc:creator>sushilc</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/474454.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=474454</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;I just &lt;a href="http://blogs.msdn.com/dataaccess/archive/2005/09/27/474447.aspx"&gt;posted a blog on our team webpage&amp;nbsp;&lt;/A&gt;on the changes in new SqlDependency feature from Beta 2 to RTM. There have been a lot of changes since we shipped in Beta 2. Do let us&amp;nbsp; know what you think of the new changes. We are looking forward to hear about this.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=474454" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Notification+Support/default.aspx">Notification Support</category></item><item><title>See you at PDC05!</title><link>http://blogs.msdn.com/sushilc/archive/2005/09/12/464186.aspx</link><pubDate>Tue, 13 Sep 2005 00:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:464186</guid><dc:creator>sushilc</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/464186.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=464186</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;I am here at PDC05, LA&amp;nbsp;represeting the SQL Server team as part of staffing the product pavillion. There is just one word to sum up the level of&amp;nbsp;excitment/ enthusiasm&amp;nbsp;that I feel in the air - WOW! And I have been told that its just starting, with more people coming in for the main event that starts tomorrow, it going to get even better. Imagine that!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;This being my first PDC, I am fired up to meet customers and partners.&amp;nbsp; I just wanted to share some of the DataWorks (my team) activities at PDC:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Tahoma&gt;&lt;FONT size=2&gt;As part of the staff duties, here is the &lt;/FONT&gt;&lt;a href="http://blogs.msdn.com/dataaccess/archive/2005/09/12/464092.aspx"&gt;&lt;FONT size=2&gt;schedule &lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt;of where you can find me at PDC. &lt;/FONT&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Tahoma&gt;&lt;FONT size=2&gt;Pablo Castro (ADO.Net, technical lead) will be giving an advance&amp;nbsp;talk on ADO.Net. &lt;/FONT&gt;&lt;a href="http://blogs.msdn.com/dataaccess/archive/2005/09/08/462494.aspx"&gt;&lt;FONT size=2&gt;Here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt; is a brief summary of his talk. I did get a sneak peak to his talk and it definetly gives lot of good information. The talk focusses on how the&amp;nbsp;some of the&amp;nbsp;new features&amp;nbsp;in &amp;nbsp;2.0 can be used in "real"&amp;nbsp;apps when it comes to large data that would make it more performant and scalable.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;If you need more information, just drop me a line or see you in LA!&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=464186" width="1" height="1"&gt;</description></item><item><title>ConnectionStringBuilder in ADO.Net v2.0 - a Primer</title><link>http://blogs.msdn.com/sushilc/archive/2005/03/30/403927.aspx</link><pubDate>Wed, 30 Mar 2005 23:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:403927</guid><dc:creator>sushilc</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/403927.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=403927</wfw:commentRss><description>&lt;font face="Tahoma" size="2"&gt;Do you want to know more about ConnectionStringBuilder feature in ADO.Net v2.0? If yes, then look up our &lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;&lt;A href="http://blogs.msdn.com/dataaccess/archive/2005/03/30/403926.aspx"&gt;team site&lt;/a&gt; &lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;where I posted a short introduction.&lt;/font&gt; &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=403927" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Misc/default.aspx">Misc</category></item><item><title>Our team blog is Online</title><link>http://blogs.msdn.com/sushilc/archive/2005/03/20/399390.aspx</link><pubDate>Sun, 20 Mar 2005 18:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:399390</guid><dc:creator>sushilc</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/399390.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=399390</wfw:commentRss><description>&lt;p&gt;&lt;font face="Tahoma" size="2"&gt;The team in which I work is called DataWorks. I am excited to announce that&amp;nbsp;we as a team have our own Web Log at &lt;A href="http://blogs.msdn.com/dataaccess"&gt;&lt;strong&gt;http://blogs.msdn.com/dataaccess&lt;/strong&gt;&lt;/a&gt;. Check&amp;nbsp;out the message from our PUM (Product Unit Manager) - Alyssa.&amp;nbsp;&amp;nbsp;Via this blog, we look forward to get feedback from&amp;nbsp;you for the components we release.&amp;nbsp; Check it out!&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=399390" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Misc/default.aspx">Misc</category></item><item><title>Getting Notifications to Work.</title><link>http://blogs.msdn.com/sushilc/archive/2005/01/31/363900.aspx</link><pubDate>Mon, 31 Jan 2005 17:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:363900</guid><dc:creator>sushilc</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/363900.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=363900</wfw:commentRss><description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;With good things said about Notification in my previous blog, I will like to take a step further to walk you through some &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;common issues in setting up this feature. We would need to undestand how notifications internally work to track some of these issues. Lets start with the SqlDependency object. When we create a SqlDependency object we are creating a listener on the client to track notifications sent by the server. There are two types of protocol options that SqlDependency supports – HTTP and TCP when creating a listener. The HTTP listener uses the HTTP.SYS functionality to create a listener. By default when no protocol option is specified, we try to create an HttpListener; if that for some reason fails, we create a TCPListener. When a change occurs, the server then dispatches notification messages via a &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:mswterms w:st="on"&gt;.Net&lt;/st1:mswterms&gt; Procedure to the client listener. Now, let’s go over some&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;common issues.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol style="MARGIN-TOP: 0in" type="1"&gt; &lt;li class="MsoNormal" style="MARGIN: 0in 0in 0pt; COLOR: #333399; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;My Application doesn’t&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;get Notification messages at all:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;There could be many reasons why we could end up with this. Here are some reasons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol style="MARGIN-TOP: 0in" type="1"&gt; &lt;ol style="MARGIN-TOP: 0in" type="a"&gt; &lt;li class="MsoNormal" style="MARGIN: 0in 0in 0pt; COLOR: maroon; mso-list: l0 level2 lfo1; tab-stops: list 1.0in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Is CLR enabled on &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt;?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 99pt"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Cause&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: Since the code on the &lt;st1:mswterms w:st="on"&gt;SQL server&lt;/st1:mswterms&gt; that dispatches notification messaged to the client is a &lt;st1:mswterms w:st="on"&gt;.Net&lt;/st1:mswterms&gt; Procedure, you will have to enable CLR on Server. We are working on not requiring this restriction.:)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 81pt; TEXT-INDENT: 0.25in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Solution&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: Here is way to do this for now,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 99pt"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Tahoma; mso-ansi-language: EN"&gt;EXEC sp_configure 'show advanced options', '1'&lt;br /&gt;go&lt;br /&gt;RECONFIGURE&lt;br /&gt;go&lt;br /&gt;EXEC sp_configure 'clr enabled', 1&lt;br /&gt;go&lt;br /&gt;RECONFIGURE&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Tahoma"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 81pt; TEXT-INDENT: 0.25in"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol style="MARGIN-TOP: 0in" type="1"&gt; &lt;ol style="MARGIN-TOP: 0in" type="a" start="2"&gt; &lt;li class="MsoNormal" style="MARGIN: 0in 0in 0pt; COLOR: maroon; mso-list: l0 level2 lfo1; tab-stops: list 1.0in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Does the SQL user have permissions on the Queue and/or the Service &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 99pt"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Cause&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: Since this feature uses the &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt; Service Broker (aka SSB) infrastructure to get notification, the user has to have the permissions on the Notification Service.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 81pt; TEXT-INDENT: 0.25in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Solution&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: To grant the permission to user ‘Willy’ on the Service and queue use:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none; tab-stops: .25in .75in 1.25in 1.75in 2.25in 2.75in 3.25in 3.75in 4.25in 4.75in 5.25in 5.75in 6.25in 6.75in 7.25in 7.75in 8.25in 8.75in 9.25in 9.75in 10.25in 10.75in 11.25in 11.75in 12.25in 12.75in 13.25in 13.75in 14.25in 14.75in 15.25in 15.75in"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Tahoma"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Tahoma"&gt;GRANT SEND on service::SqlQueryNotificationService to Willy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 81pt; TEXT-INDENT: 0.25in"&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Tahoma"&gt;GRAND RECEIVE on SqlQueryNotificationService_DefaultQueue to Willy&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 81pt; TEXT-INDENT: 0.25in"&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Tahoma"&gt;Also the user needs permission to subscribe to notification. To do this use:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 81pt; TEXT-INDENT: 0.25in"&gt;&lt;span lang="EN" style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Tahoma; mso-ansi-language: EN"&gt;GRANT SUBSCRIBE QUERY &lt;span class="searchword"&gt;NOTIFICATION&lt;/span&gt;S TO Willy&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Tahoma"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 81pt; TEXT-INDENT: 0.25in"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol style="MARGIN-TOP: 0in" type="1"&gt; &lt;ol style="MARGIN-TOP: 0in" type="a" start="3"&gt; &lt;li class="MsoNormal" style="MARGIN: 0in 0in 0pt; COLOR: maroon; mso-list: l0 level2 lfo1; tab-stops: list 1.0in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Is it an XPSP2 machine and/or you using a firewall to block ports?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 99pt"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Cause&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: As said above, Notifications are dispatched from the server to the client via listener that sits on the client. With XPSP2 we have firewall enabled by default. Since the firewall will block any message sent to your TCP/HTTP ports, this may not generate Notification event. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 99pt"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Solution&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: Make sure these are open for the application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 99pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;ol style="MARGIN-TOP: 0in" type="1" start="2"&gt; &lt;li class="MsoNormal" style="MARGIN: 0in 0in 0pt; COLOR: #333399; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;I get an instantaneous notification telling that the Subscription failed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Cause&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: There are set of requirements that are placed on the queries for which are notifiable . Basically, the restrictions are quite similar to restrictions for Indexed Views in &lt;st1:mswterms w:st="on"&gt;SQL Server&lt;/st1:mswterms&gt; 2000. More information on these requirements can be found at &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_06_9jnb.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_06_9jnb.asp&lt;/a&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;Solution&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"&gt;: Queries that pass the above requirements can only be used.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" color="#000080" size="1"&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=363900" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Notification+Support/default.aspx">Notification Support</category></item><item><title>Guerrilla SQL Server 2005 class</title><link>http://blogs.msdn.com/sushilc/archive/2004/12/17/323647.aspx</link><pubDate>Fri, 17 Dec 2004 17:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:323647</guid><dc:creator>sushilc</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/323647.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=323647</wfw:commentRss><description>&lt;p&gt;&lt;font face="Tahoma" size="2"&gt;I happened to go to one of the class from a mentoring company. It was presented by Bob Beauchemin-Niels Berglund-Dan &lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;Sullivan. Boy! they were great! &lt;br /&gt;I was just in time for the ADO.Net presentation that Bob made. He talked about top 3 features that he liked in ADO.Net&lt;br /&gt;1. &lt;strong&gt;Provider Factory&lt;/strong&gt; - He talked at great lengths about how easy it was to use provider factory to write generic code&lt;br /&gt;2. &lt;strong&gt;Meta Data/GetSchema&lt;/strong&gt; - The easy way to get meta data Schema. More information in his article in MSDN - (&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/adonet2schemas.asp"&gt;link&lt;/a&gt;)&lt;br /&gt;3. &lt;strong&gt;Tracing&lt;/strong&gt; - Yes, we shipped a way for you to get trace output from System.Data internal code. Now this is the feature that &lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;was not that well documented in Beta docs, but &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/tracingdataaccess.asp"&gt;this&lt;/a&gt; article (written by bob, grin) does a very good job explaining the internals &lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;and how to get it working.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;It was great to see these guys present. They were awesome and great! (Oh, did I already say that :))&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=323647" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Misc/default.aspx">Misc</category></item><item><title>Notification Support in SqlClient Managed Provider</title><link>http://blogs.msdn.com/sushilc/archive/2004/12/07/277701.aspx</link><pubDate>Tue, 07 Dec 2004 17:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:277701</guid><dc:creator>sushilc</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/277701.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=277701</wfw:commentRss><description>&lt;p&gt;&lt;font size="2"&gt;&lt;font face="Tahoma"&gt;After a brief hiatus, let me start with&amp;nbsp;blogging the new Notification support in SqlClient MP that is introduced in Whidbey. There are scenarios in which an application would store a cache of data obtain from a DB Server and then re-query from the same cache to save round-trips to the server (for better performance). Typically, the app would want some mechanism to be notified when this very cache was changed by some one.&amp;nbsp;&lt;/font&gt;&lt;font face="Tahoma"&gt;In short, this feature allows you to monitor a specified result-set (collection on table rows,&amp;nbsp; as defined by your select statement.) and then notify you when something is changed in the monitored result-set. &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;In this blog, I will just post a sample illustrating on how easy it is to set a result-set for Notification. In the upcoming blogs,&amp;nbsp;I will get into more&amp;nbsp;details with some gotchas, tips and tricks with Notifications.&amp;nbsp;&lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;Lets see how simple its to get this working. Lets say way, create a table test with following TSQL&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#0000ff" size="2"&gt;create table test (i int)&lt;br /&gt;go&lt;br /&gt;insert into test values (1)&lt;br /&gt;insert into test values (2)&lt;br /&gt;insert into test values (3)&lt;br /&gt;insert into test values (4)&lt;br /&gt;go&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;The following sample shows how a console application that reads data from the 'test' table into its cache and will get notified if some one has made changes to this &lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;cache on the server.&lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt; System;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt; System.Data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt; System.Data.SqlClient;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;class&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt; QuikExe&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; connectionstring = "&lt;font color="#ff0000"&gt;Put you connection string here&lt;/font&gt;";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; DoDependency()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; (SqlConnection conn = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; SqlConnection (connectionstring)) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;conn.Open();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Connection Opened&lt;font face="Courier New" color="#0000ff"&gt;...&lt;/font&gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SqlCommand cmd = conn.CreateCommand();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cmd.CommandText = "Select i from dbo.test";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//Notification specific code&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SqlDependency dep = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; SqlDependency (cmd);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;dep.OnChanged += &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; OnChangedEventHandler(TestEvent);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SqlDataReader r = cmd.ExecuteReader();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//Read the data here and close the reader&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;r.Close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("DataReader Read&lt;font face="Courier New" color="#0000ff"&gt;...&lt;/font&gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt; TestEvent(Object o,SqlNotificationEventArgs args)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Event Recd");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Info:" + args.Info );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Source:"+args.Source );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Type:"+args.Type );&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;QuikExe q = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; QuikExe();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;q.DoDependency();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Wait for Notification Event&lt;font face="Courier New" color="#0000ff"&gt;...&lt;/font&gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.Read();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;}&lt;/span&gt;&lt;span style="FONT-FAMILY: Courier"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;Run the above application and you will see the following output&lt;br /&gt;&lt;font face="Courier New" color="#0000ff"&gt;Connection Opened...&lt;br /&gt;DataReader Read...&lt;br /&gt;Wait for Notification Event...&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;To verify that we indeed get a notification when the test table is change. Now invalidate the cache that we read using the following T-SQL statement (using any client tools-Workbench or another console Application :))&lt;br /&gt;&lt;font face="Courier New" color="#0000ff"&gt;insert into test values (5)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;Now, you will see the following Notification message from the above application&lt;br /&gt;&lt;font face="Courier New" color="#0000ff"&gt;Event Recd&lt;br /&gt;Info:Insert&lt;br /&gt;Source:Data&lt;br /&gt;Type:Change&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;Great! All we did here was to create a SqlDependency object and associate the Command to it before executing.&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SqlDependency dep = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; SqlDependency (cmd);&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Tahoma" size="2"&gt;Also, to get notified we added a call-back event.&lt;br /&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;dep.OnChange += &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; OnChangeEventHandler(TestEvent);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;The SqlNotificationEventArgs in turn has three properties which are enums:&lt;br /&gt;1. &lt;em&gt;Info&lt;/em&gt; - Gives information on what caused the notification. &lt;br /&gt;2. &lt;em&gt;Source&lt;/em&gt; - Gives the source of this notification. &lt;br /&gt;3. &lt;em&gt;Type&lt;/em&gt; - Type of notification. &lt;br /&gt;Since in our case an &lt;em&gt;&lt;strong&gt;Insert&lt;/strong&gt;&lt;/em&gt; statement caused a &lt;em&gt;&lt;strong&gt;Change&lt;/strong&gt;&lt;/em&gt; in &lt;em&gt;&lt;strong&gt;Data&lt;/strong&gt;&lt;/em&gt;. The args properties are set as &lt;u&gt;Info=Insert;Source=Data;Type=Change;&lt;/u&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;Note: Since the supporting functionality that makes this happen (SSB)&amp;nbsp; is only available in SQL Server 2005 (Yukon), the above code will only&amp;nbsp;work with SQL&amp;nbsp;Server 2005.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;So how did all this happen? In SQL Server 2005, we have a SSB service running in the MSDB database (called the SqlQueryNotificationService). When a command associated with a SqlDependency executes; it makes a request to this service for being notified if there occurred any change in the obtained result set. When a change occurs, the SSB service then puts&amp;nbsp; a notification message in a specified Queue. The server then send the message from the queue to the client. The client then calls the call-back Event appropriately.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;Tips and tricks to be aware while using SqlDependency is coming soon,&lt;br /&gt;Stay posted.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" size="2"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=277701" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Notification+Support/default.aspx">Notification Support</category></item><item><title>Enumerating SQL Servers</title><link>http://blogs.msdn.com/sushilc/archive/2004/10/14/242395.aspx</link><pubDate>Thu, 14 Oct 2004 18:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:242395</guid><dc:creator>sushilc</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/242395.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=242395</wfw:commentRss><description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;Continuing with the discussion on enumeration, I will go over ways to enumerate active SQL servers on the network in this blog. Pre-Whidbey, to get list of active servers on the network, we could have done Inter-Op calls to server enumeration APIs in OleDb. If we wanted to write only managed code,we could have broad-casted a carefully crafted UDP packet to the network on port 1434 and waited for response from active SQL Servers and then list them.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;In Whidbey, there is an API provided to do the server enumeration. It allows to list active servers on the network. Here is the sample code:&lt;/font&gt;&lt;/p&gt;&lt;font face="Verdana" size="2"&gt;&lt;/font&gt;&lt;font face="Courier New" color="#0000ff" size="2"&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt; System.Data;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt; System.Data.Sql;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt; System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;class&lt;/span&gt;&lt;font color="#000000"&gt; Repro&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 1"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;static&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&lt;font color="#000000"&gt; &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;Main&lt;/st1:place&gt;(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color="#000000"&gt;[] args)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SqlDataSourceEnumerator sqldatasourceenumerator1 = SqlDataSourceEnumerator.Instance;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DataTable datatable1 = sqldatasourceenumerator1.GetDataSources();&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt;&lt;font color="#000000"&gt; (DataRow row &lt;/font&gt;&lt;span style="COLOR: blue"&gt;in&lt;/span&gt;&lt;font color="#000000"&gt; datatable1.Rows)&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("****************************************");&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Server Name:"+row["ServerName"]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Instance Name:"+row["InstanceName"]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Console.WriteLine("Is Clustered:"+row["IsClustered"]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;font color="#000000"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang="FR" style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: FR"&gt;Console.WriteLine("Version:"+row["Version"]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;font color="#000000"&gt;&lt;span lang="FR" style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-ansi-language: FR"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;Console.WriteLine("****************************************");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;span style="mso-tab-count: 2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color="#000000"&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;&lt;font color="#000000"&gt;}&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Courier"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br /&gt;****************************************&lt;br /&gt;Server Name:TESTSERVER-D1&lt;br /&gt;Instance Name:&lt;br /&gt;Is Clustered:No&lt;br /&gt;Version:8.00.194&lt;br /&gt;****************************************&lt;br /&gt;****************************************&lt;br /&gt;Server Name:TESTSERVER01&lt;br /&gt;Instance Name:INST2&lt;br /&gt;Is Clustered:No&lt;br /&gt;Version:8.00.194&lt;br /&gt;****************************************&lt;br /&gt;****************************************&lt;br /&gt;Server Name:TESTSERVER3&lt;br /&gt;Instance Name:&lt;br /&gt;Is Clustered:No&lt;br /&gt;Version:8.00.194&lt;br /&gt;****************************************&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;What did we do here? SqlDataSourceEnumerator has a public static property that returns an instance of SqlDataSourceEnumerator . The GetDataSources() method on the Enumerator returns a datatable that returns list of active Servers on the network. Following information about the server is included in the table:&lt;br /&gt;1.&lt;strong&gt;Server Name&lt;/strong&gt;: Name of the server.&lt;br /&gt;2.&lt;strong&gt;Instance Name&lt;/strong&gt;: Name of the SQL Server instance. &lt;em&gt;&lt;u&gt;If its a default instance then this is DBNull&lt;/u&gt;.&lt;br /&gt;&lt;/em&gt;3.&lt;strong&gt;Is Clustered&lt;/strong&gt;: returns Yes, if Server is clustered, else No.&lt;br /&gt;4.&lt;strong&gt;Version&lt;/strong&gt;: returns the full version number of the server listed.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;&lt;em&gt;Q:Why do we have a static property Instance on&amp;nbsp; SqlDataSourceEnumerator ?&lt;br /&gt;&lt;/em&gt;A:The Instance property is a result of the factorization of the class. The base class, DbDataSourceEnumerator, defines the abstract GetDataSources method. This way, all derived enumerators have to implement it. This implies the method has to be instance method and cannot be static. To make it easy to write code we just added&amp;nbsp;a static property on SqlDataSourceEnumerator that gives its instance.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;&lt;em&gt;Q:Why are some values for InstanceName, IsClustered and Version DBNull?&lt;br /&gt;&lt;/em&gt;A:The Enumeration API that SQL Client Managed Provider calls, first broadcasts the 'special' packet on port 1434 and waits for a timeout. The replies that it receives with-in the timeout contain all the required information to populate the DataTable. In addition to this,the API looks at the Active Directory (AD) to list the other servers that did not reply for the broadcast packet. There is no way to know the values for &lt;em&gt;InstanceName, IsClustered and Version &lt;/em&gt;when listed via AD and hence they are DBNull.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;&lt;em&gt;Q:Why are all servers on the network not listed in the list?&lt;br /&gt;&lt;/em&gt;A:Since we wait for a time-out it is not guaranteed that we return all the active servers on the network. In fact, the list is most likely to give a different list depending on the network I/O, server performance and other time-depending constraints.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" color="#000080" size="1"&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=242395" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Provider+and+Server+Enumeration/default.aspx">Provider and Server Enumeration</category></item><item><title>Using Provider Factories</title><link>http://blogs.msdn.com/sushilc/archive/2004/10/08/239991.aspx</link><pubDate>Fri, 08 Oct 2004 21:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:239991</guid><dc:creator>sushilc</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/239991.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=239991</wfw:commentRss><description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;There are situation in real world; when you dont want to write code, dependent on just one of the managed provider. This also helps to easily move from using one provider to another if the code design changes in the future. &lt;/font&gt;&lt;font face="Verdana" size="2"&gt;Pre-Whidbey, the only way to do this was to write your own wrapper classes for the providers. In whidbey this can be done usign ProviderFactories. Here is a sample code:&lt;/font&gt;&lt;/p&gt;&lt;font style="BACKGROUND-COLOR: #ffffff" face="Verdana" size="2"&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; System.Data.Common;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; System.Data;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; System;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; System.Data.SqlClient;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;namespace&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; DataViewer.Repro&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Repro&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;Main&lt;/st1:place&gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[] args)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; conString = "ConnectionString here";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; cmdText = "CommandText here";&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//Select SQL Client factory - Can change to use any provider later&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;DbProviderFactory&lt;/span&gt; factory = &lt;span style="COLOR: teal"&gt;DbProviderFactories&lt;/span&gt;.GetFactory("System.Data.SqlClient");&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//Create Connection from the factory&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;DbConnection&lt;/span&gt; cn = factory.CreateConnection();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cn.ConnectionString = conString;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cn.Open();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//Create Command from the factory&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;DbCommand&lt;/span&gt; cmd = factory.CreateCommand();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: green"&gt;//Execute a command from the conneciton&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cmd.Connection = cn;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cmd.CommandText = cmdText;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;DbDataReader&lt;/span&gt; reader = cmd.ExecuteReader();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;while&lt;/span&gt; (reader.Read())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(reader.GetValue(0));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;/font&gt;&lt;font face="Verdana" size="2"&gt;After the provider is selected, there is no reference to any of the managed providers in the above code. The above code infact uses the SqlClient MP. In similar way, you can then use the factories to create Parameter, ConnectionStringBuilder, DataSourceEnumerator, Adapter, CommandBuilder and Permissions classes.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Caution:&lt;br /&gt;1. Generalization might also cause an extra overhead.&lt;br /&gt;2. When writing genralized code, you will not be able to use features that are provider specific. You would have to special case them.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" color="#000080" size="1"&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=239991" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Provider+and+Server+Enumeration/default.aspx">Provider and Server Enumeration</category></item><item><title>Provider Enumeration in Whidbey</title><link>http://blogs.msdn.com/sushilc/archive/2004/10/07/239359.aspx</link><pubDate>Thu, 07 Oct 2004 19:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:239359</guid><dc:creator>sushilc</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/239359.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=239359</wfw:commentRss><description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;I have been wanting to post for a long time now, and have finally decided to FIGHT my&amp;nbsp;slackness. I will continue with my views on some of the new features in ADO.Net for Whidbey. I will start with talking about a new feature in Whidbey - Provider Enumeration.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Pre-Whidbey there was no way to know if a particular provider is available on your computer. In addition there was no API from ADO.Net that&amp;nbsp;allowed you&amp;nbsp;to choose a provider at execution time (by some cool looking UI)&amp;nbsp;and then run the Application, written in a provider-independent way with the selected provider. There could be scenarios in which getting this list of providers seamlessly from the API could be useful.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;In Whidbey, there is a way to enumerate the providers on the computer. Here is a sample program that does just that:&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#0000ff" size="2"&gt;using System.Data;&lt;br /&gt;using System.Data.Common;&lt;br /&gt;using System;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#0000ff" size="2"&gt;public class Repro&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;public static int Main(string[] args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataTable datatable1 = DbProviderFactories.GetFactoryClasses();&amp;nbsp;// DbProviderFactories&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach (DataRow row in datatable1.Rows) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine("Provider Name:"+row["Name"]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine("Provider Description:"+row["Description"]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine("Provider Invariant Name:"+ row["InvariantName"]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine("**************************************************************");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#000000" size="2"&gt;Output:&lt;/font&gt;&lt;font face="Courier New" color="#0000ff" size="1"&gt;Provider Name:Odbc Data Provider&lt;br /&gt;Provider Description:.Net Framework Data Provider for Odbc&lt;br /&gt;Provider Invariant Name:System.Data.Odbc&lt;br /&gt;**************************************************************&lt;br /&gt;Provider Name:OleDb Data Provider&lt;br /&gt;Provider Description:.Net Framework Data Provider for OleDb&lt;br /&gt;Provider Invariant Name:System.Data.OleDb&lt;br /&gt;**************************************************************&lt;br /&gt;Provider Name:OracleClient Data Provider&lt;br /&gt;Provider Description:.Net Framework Data Provider for Oracle&lt;br /&gt;Provider Invariant Name:System.Data.OracleClient&lt;br /&gt;**************************************************************&lt;br /&gt;Provider Name:SqlClient Data Provider&lt;br /&gt;Provider Description:.Net Framework Data Provider for SqlServer&lt;br /&gt;Provider Invariant Name:System.Data.SqlClient&lt;br /&gt;**************************************************************&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;What did I just do? The &lt;font face="Courier New" color="#0000ff"&gt;DbProviderFactories &lt;font face="Verdana" color="#000000"&gt;has a static method &lt;font face="Courier New" color="#0000ff"&gt;GetFactoryClasses&lt;/font&gt; that enumerates through all the providers that are on my system and returns it as a DataTable. Then I iterate throw all the rows in the DataTable in the foreach statement and print the output.&amp;nbsp;The returned table&amp;nbsp;has 5 columns with the following Column Names&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;Name: this&amp;nbsp;has the Name of the provider&amp;nbsp;&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;Description: describes what the provider does&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;InVariantName: returns the invariant name of the assembly&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;AssemblyQualifiedName: a fully qualified assembly name&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana" size="2"&gt;Supported classes: Gets the value of DbProviderSupportedClasses, which tells the set of of classes (Connection, Command, DataReader, Adapter) that this provider supports.&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Q: Where is the information about the provider got from?&lt;br /&gt;A: All this information about the provider is received from the Configuration file. (This could be any of the config file- machine-level, app-level or user-level)&lt;/font&gt;&lt;/p&gt;&lt;font face="Verdana" size="2"&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;Q: Why doesn't a third party provider does not feature in the list even when the provider is installed on my machine?&lt;br /&gt;A:&amp;nbsp;There is no standard way to know if&amp;nbsp;a 3rd party provider is installed on the system. Since the enumeration shows only the information available in the configuration file, to make it appear in the list the information pertaining to the provider should be mentioned in the config file.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;/font&gt;&lt;font face="Verdana" size="2"&gt;In the next blog, I will post how you can use the Factory classes to build provider independent code. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Tahoma" color="#000080" size="1"&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=239359" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/Provider+and+Server+Enumeration/default.aspx">Provider and Server Enumeration</category></item><item><title>Typed XML in ADO.Net v2.0</title><link>http://blogs.msdn.com/sushilc/archive/2004/08/04/208250.aspx</link><pubDate>Wed, 04 Aug 2004 20:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:208250</guid><dc:creator>sushilc</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/208250.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=208250</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;In the earlier sections, we have been looking at Untyped XML which are different from Typed XML. Typed XML data type is an XML defined with&amp;nbsp;an associated xml&amp;nbsp;schema in Sql Server 2005.&amp;nbsp;You may ask if there is anything different on how Typed XML are exposed via ADO.Net 2.0. The answer is a heart-warming NO!. Typed XML are exposed the same way that any untyped XML does through SqlDataReader and SqlParameter. Please note that the check to see if the given XML adheres to the give schema is not done on the client side. This check is done when the statement is executed on the server side.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;There are new set of columns added to the DataTable returned from SqlDataReader.GetSchemaTable() method that give extra information pertaining to the associated XML Schema. The three columns that are added are:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Tahoma&gt;&lt;FONT size=2&gt;XmlSchemaCollectionDatabase:&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;Provides&amp;nbsp;the database in which the schema for this XML type exists.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT face=Tahoma&gt;XmlSchemaCollectionOwningSchema:&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;Provides the owning relational schema where the schema for this XML instance is located&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT face=Tahoma&gt;XmlSchemaCollectionName: Provides the &lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;name of the schema for this XML type.&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;FONT face=Tahoma&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;Consider the typed XML is defined with the following TSQL:&lt;BR&gt;&lt;FONT color=#0000ff&gt;-- Change to Library database&lt;BR&gt;USE &lt;STRONG&gt;Library&lt;/STRONG&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Tahoma&gt;&lt;FONT color=#0000ff&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;-- OrderSchema is defined using the CREATE XML SCHEMA COLLECTION statement&lt;BR&gt;CREATE XML SCHEMA COLLECTION &lt;STRONG&gt;OrderSchema&lt;/STRONG&gt; AS&lt;BR&gt;N'XSD_DEFINITION_HERE'&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;-&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;-&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Tahoma color=#0000ff&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;Consider the Schema/namespace&lt;BR&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;FONT face=Tahoma&gt;&lt;FONT color=#0000ff&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;-- Customer table is created with a Typed XML column name OrderXml&lt;BR&gt;&lt;/SPAN&gt;CREATE TABLE &lt;STRONG&gt;Customer&lt;/STRONG&gt; (CustomerId int, CustomerName varchar(40), OrderXml xml(OrderSchema))&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;The three-part name of the embedded XML schema can be got as follows:&lt;/FONT&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;sqlcommand1.CommandText = "SELECT OrderXml from Customer";&lt;BR&gt;SqlDataReader sqldatareader1 = sqlcommand1.ExecuteReader();&lt;BR&gt;DataTable datatable1 = sqldatareader1.GetSchemaTable();&amp;nbsp;// SchemaTable&lt;BR&gt;Console.WriteLine(datatable1.Rows[0]["XmlSchemaCollectionDatabase"]); //returns &lt;STRONG&gt;Library&lt;/STRONG&gt;&lt;BR&gt;Console.WriteLine(datatable1.Rows[0]["XmlSchemaCollectionOwningSchema"]); //returns &lt;STRONG&gt;dbo&lt;/STRONG&gt;&lt;BR&gt;Console.WriteLine(datatable1.Rows[0]["XmlSchemaCollectionName"]); //retuns &lt;STRONG&gt;OrderSchema&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=208250" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/SQL+Server_2700_s+Xml+DataType+w_2F00_ADO.Net+2.0/default.aspx">SQL Server's Xml DataType w/ADO.Net 2.0</category></item><item><title>XML Data type in ADO.Net v2.0 - Part II</title><link>http://blogs.msdn.com/sushilc/archive/2004/08/03/207162.aspx</link><pubDate>Tue, 03 Aug 2004 16:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:207162</guid><dc:creator>sushilc</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/207162.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=207162</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;In this section we will look at ways ADO.Net v2.0 (Code named 'Whidbey') allows us to insert/delete/update Xml data values in a table containing Xml column in SQL Server 2005 (Code named 'Yukon').&amp;nbsp; With earlier versions of the .Net Framework (1.0 and 1.1) the System.Data.SqlClient namespace will consume and emit XML as String values.Because of this, it should&amp;nbsp;not be a&amp;nbsp;surprise that they would behave the same way with Whidbey.&amp;nbsp;This was made so as&amp;nbsp;to not break customers using this&amp;nbsp;new datatype of the Server with&amp;nbsp;older versions of the framework. &lt;I&gt;Note: The examples below use the Customer table defined in the &lt;A href="http://blogs.msdn.com/sushilc/archive/2004/07/29/201042.aspx"&gt;Part I &lt;/A&gt;of the blog.&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;&lt;U&gt;Xml Values from DataReader:&lt;/U&gt; &lt;/STRONG&gt;XML values in SqlDataReader are surfaced like any other type. The GetValue() method will get the Xml Value as String where as the GetSqlValue() method will get the value as an instance of SqlString. The following examples show both of the retrieval methods.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;B&gt;Get Value as XmlReader&lt;BR&gt;&lt;/B&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (SqlCommand Cmd = Conn.CreateCommand())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.CommandText= "SELECT OrderXml FROM Customer WHERE CustomerId = 2";&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlDataReader Reader = Cmd.ExecuteReader();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Reader.Read()) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string XmlValue = (string) Reader.GetValue(0); //Gets the XML value as string&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;B&gt;Get Value as SqlXml&lt;/B&gt;: With ADO.Net 2.0, we have introduced a new class SqlXml. This new class adds SQL-specific feature like null semantics to the XML type. This is consistent with other SqlTypes (like SqlString for VARCHAR, SqlInt16 for Integer). This class allows the user to create an XmlReader (not to be confused with DataReader) on the SqlXml value using the SqlXml.CreateReader method. An example is shown below:&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (SqlCommand Cmd = Conn.CreateCommand())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.CommandText= "SELECT OrderXml FROM Customer WHERE CustomerId = 2";&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;SqlDataReader Reader = Cmd.ExecuteReader();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (Reader.Read()) &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; SqlXml SqlXmlValue = Reader.GetSqlXml(0);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PrintXmlReader(SqlXmlValue.CreateReader()); //Gets the XmlReader from SqlXml object and prints it using a Helper function&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;/FONT&gt;Note:&lt;BR&gt;1. In the above examples, SqlClient Managed Provider internally converts the Binary formatted XML that it receives from the server into string representation. &lt;BR&gt;2. To get the XmlReader object for the XML data type, use the SqlXml.CreateReader method.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;B&gt;&lt;U&gt;Parameterized&lt;/U&gt; &lt;U&gt;Xml Values&lt;/U&gt;&lt;BR&gt;&lt;/B&gt;XML values can also be used in parameters. The value itself can be expressed as a string, an XmlReader-derived type instance or a SqlXml object. Examples below show how to set the parameters for each of these values.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;B&gt;Xml Value as String &lt;/B&gt;In this example, the string is directly used to set the Parameter's Value&lt;B&gt;&lt;BR&gt;&lt;/B&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp; using (SqlConnection Conn = new SqlConnection (ConnectionString))&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Conn.Open();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (SqlCommand Cmd = Conn.CreateCommand())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //INSERT VALUES using PARAMS &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;XmlReader XmlValue = new XmlTextReader("Sample.Xml");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.CommandText = "INSERT INTO Customer VALUES (4,'Chris Andrews',@XmlFile)";&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.Parameters.AddWithValue("@XmlFile", &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;"&amp;lt;order&amp;gt;&amp;lt;item&amp;gt;&amp;lt;id&amp;gt;20&amp;lt;/id&amp;gt;&amp;lt;name&amp;gt;Widgets&amp;lt;/name&amp;gt;&amp;lt;units&amp;gt;3&amp;lt;/units&amp;gt;&amp;lt;/item&amp;gt;&amp;lt;/order&amp;gt;"&lt;/FONT&gt;&lt;FONT face=Tahoma size=2&gt;&lt;FONT color=#0000ff&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.ExecuteNonQuery();&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;}&lt;/FONT&gt;&lt;BR&gt;&lt;B&gt;Xml Value as SqlXml&lt;/B&gt;&lt;BR&gt;Just like other types, SQL-specific type for XML can be used to set the Parameter's value for XML. SqlXml ctor() takes XmlReader or a Stream. The following example creates an instance of XmlTextReader and then sets the value of the parameter. An instance of XmlTextReader is created by opening a file with name:"Sample.Xml".&amp;nbsp; &lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (SqlConnection Conn = new SqlConnection (ConnectionString))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Conn.Open();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using (SqlCommand Cmd = Conn.CreateCommand())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //INSERT VALUES using PARAMS &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.CommandText = "INSERT INTO Customer VALUES (4,'Chris Andrews',@XmlFile)";&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlXml SqlXmlValue = new SqlXml( new XmlTextReader ("SampleInfo.Xml")); // This passes the file SampleInfo.Xml as the parameter's value&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.Parameters.AddWithValue("@XmlFile", SqlXmlValue);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Cmd.ExecuteNonQuery();&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;/FONT&gt;Note: You have to make sure that the XmlReader that is passed as an argument is on the top most node, else partial results will be inserted in the table, depending on the current position of the XmlReader.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=207162" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/SQL+Server_2700_s+Xml+DataType+w_2F00_ADO.Net+2.0/default.aspx">SQL Server's Xml DataType w/ADO.Net 2.0</category></item><item><title>XML Data type in ADO.Net v2.0 - Part I</title><link>http://blogs.msdn.com/sushilc/archive/2004/07/29/201042.aspx</link><pubDate>Thu, 29 Jul 2004 20:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:201042</guid><dc:creator>sushilc</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/sushilc/comments/201042.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sushilc/commentrss.aspx?PostID=201042</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;After a long hiatus, let me start with how the new XML data type in SQL Server 2005 is exposed via ADO.Net 2.0. I will discuss this new data type in following parts:&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Tahoma size=2&gt;XML data type in SQL Server 2005 &amp;#8211; A brief Introduction : You can consider this as a crash course on XML data type in SQL Server 2005.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Tahoma size=2&gt;ADO.Net 2.0 and XML DataType&lt;/FONT&gt; 
&lt;OL type=a&gt;
&lt;LI&gt;&lt;FONT face=Tahoma size=2&gt;Getting XML values from SqlDataReader.&lt;/FONT&gt; 
&lt;LI&gt;&lt;FONT face=Tahoma size=2&gt;Passing XML values as Parameters&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;The following is section 1 of the 2 part series:&lt;/FONT&gt;&lt;/P&gt;&lt;B&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;XML data type in SQL Server 2005 &amp;#8211; A brief Introduction&lt;/FONT&gt;&lt;/P&gt;&lt;/B&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;A new scalar data type is introduced in SQL Server 2005 for storage and retrieval of XML data. XML value that is stored in the column is basically an XML fragment like single root, multiple roots, text nodes, empty string, text nodes at the top. Consider you want to create a Customer table with the following Columns:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT face=Tahoma size=2&gt;CustomerId &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int, &lt;BR&gt;CustomerName &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; varchar(40), &lt;BR&gt;OrderXml &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xml&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;FONT face=Tahoma&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT size=2&gt;Here is an example showing how to create such a table and insert some values as literals using TSQL&lt;/FONT&gt;&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;/FONT&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;Untyped XML&lt;BR&gt;&lt;/STRONG&gt;&lt;FONT color=#0000ff&gt;CREATE TABLE Customer (CustomerId int, CustomerName varchar(40), OrderXml xml)&lt;BR&gt;go&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#0000ff size=2&gt;INSERT INTO Customer VALUES (1,'Allison Gray',&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;lt;order&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;item&amp;gt;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;id&amp;gt;20&amp;lt;/id&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;Widgets&amp;lt;/name&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;units&amp;gt;3&amp;lt;/units&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/item&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/order&amp;gt;')&lt;BR&gt;go&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;EM&gt;&lt;FONT size=1&gt;&lt;FONT size=2&gt;Fact: If the string character is Unicode then the XML values is always parsed in as UTF-16.&lt;/FONT&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/EM&gt;&amp;nbsp;&lt;BR&gt;&lt;STRONG&gt;Typed XML&lt;BR&gt;&lt;/STRONG&gt;The above XML data type is untyped meaning it is not associated with any schema. If we know that OrderXML adheres to one specific XML Schema, we can associate it to a previously loaded XML schema with the following syntax:&lt;BR&gt;&lt;FONT color=#0000ff&gt;-- Consider the Schema/namespace - OrderSchema is defined using the CREATE XML SCHEMA COLLECTION statement&lt;BR&gt;CREATE TABLE Customer (CustomerId int, CustomerName varchar(40), OrderXml xml(OrderSchema))&lt;BR&gt;go&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;STRONG&gt;XML Methods&lt;/STRONG&gt;&lt;BR&gt;In addition to the above, XML data type has some methods. Some of them are:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Tahoma size=2&gt;
&lt;OL&gt;
&lt;LI&gt;Query method: Given a XQUERY as an argument, this method performs that query on the XML data type. 
&lt;LI&gt;Value method: Given a XQUERY as an argument, this method runs the query and returns a scalar value. 
&lt;LI&gt;Exist method: Given an XQUERY as an argument, this method returns 1 if the XQuery expression returns a non-empty result from the XML column else it returns 1. 
&lt;LI&gt;Modify method: Used to modify XML data. Basically this performs XML data manipulation as specified in the arguments.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Since our goal is to see the interaction of XML data type with ADO.Net, the above introduction would suffice. There are other awesome features on XML data type on the server and are not discussed here due to the scope of the article.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=201042" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sushilc/archive/tags/SQL+Server_2700_s+Xml+DataType+w_2F00_ADO.Net+2.0/default.aspx">SQL Server's Xml DataType w/ADO.Net 2.0</category></item></channel></rss>