<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Sushil's WebLog</title><subtitle type="html">Random ADO.Net discussion</subtitle><id>http://blogs.msdn.com/b/sushilc/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/sushilc/atom.aspx" /><generator uri="http://telligent.com" version="5.6.50428.7875">Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><updated>2004-10-14T11:56:00Z</updated><entry><title>Time to resurrect my blog...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2009/06/08/time-to-resurrect-my-blog.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2009/06/08/time-to-resurrect-my-blog.aspx</id><published>2009-06-08T20:42:00Z</published><updated>2009-06-08T20:42:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9708583" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>SQL Server 2005 and Visual Studio 2005 RTM!</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2005/10/28/486348.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2005/10/28/486348.aspx</id><published>2005-10-28T22:04:00Z</published><updated>2005-10-28T22:04:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=486348" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Misc" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Misc/" /></entry><entry><title>SqlDependency changes for RTM</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2005/09/27/474454.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2005/09/27/474454.aspx</id><published>2005-09-27T19:49:00Z</published><updated>2005-09-27T19:49:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=474454" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Notification Support" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Notification+Support/" /></entry><entry><title>See you at PDC05!</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2005/09/12/464186.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2005/09/12/464186.aspx</id><published>2005-09-13T00:27:00Z</published><updated>2005-09-13T00:27:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=464186" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>ConnectionStringBuilder in ADO.Net v2.0 - a Primer</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2005/03/30/403927.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2005/03/30/403927.aspx</id><published>2005-03-30T23:22:00Z</published><updated>2005-03-30T23:22:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=403927" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Misc" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Misc/" /></entry><entry><title>Our team blog is Online</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2005/03/20/399390.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2005/03/20/399390.aspx</id><published>2005-03-20T18:49:00Z</published><updated>2005-03-20T18:49:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=399390" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Misc" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Misc/" /></entry><entry><title>Getting Notifications to Work.</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2005/01/31/363900.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2005/01/31/363900.aspx</id><published>2005-01-31T17:44:00Z</published><updated>2005-01-31T17:44:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=363900" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Notification Support" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Notification+Support/" /></entry><entry><title>Guerrilla SQL Server 2005 class</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2004/12/17/323647.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2004/12/17/323647.aspx</id><published>2004-12-17T17:44:00Z</published><updated>2004-12-17T17:44:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=323647" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Misc" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Misc/" /></entry><entry><title>Notification Support in SqlClient Managed Provider</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2004/12/07/277701.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2004/12/07/277701.aspx</id><published>2004-12-07T17:47:00Z</published><updated>2004-12-07T17:47:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=277701" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Notification Support" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Notification+Support/" /></entry><entry><title>Enumerating SQL Servers</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/sushilc/archive/2004/10/14/242395.aspx" /><id>http://blogs.msdn.com/b/sushilc/archive/2004/10/14/242395.aspx</id><published>2004-10-14T18:56:00Z</published><updated>2004-10-14T18:56:00Z</updated><content type="html">&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=242395" width="1" height="1"&gt;</content><author><name>sushilc</name><uri>http://blogs.msdn.com/sushilc/ProfileUrlRedirect.ashx</uri></author><category term="Provider and Server Enumeration" scheme="http://blogs.msdn.com/b/sushilc/archive/tags/Provider+and+Server+Enumeration/" /></entry></feed>