<?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>The Visual Basic Team : Steve Stein</title><link>http://blogs.msdn.com/vbteam/archive/tags/Steve+Stein/default.aspx</link><description>Tags: Steve Stein</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>I can no longer connect to the SQL Server on an XP SP2 machine!</title><link>http://blogs.msdn.com/vbteam/archive/2005/04/01/404675.aspx</link><pubDate>Fri, 01 Apr 2005 17:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:404675</guid><dc:creator>VBTeam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/404675.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=404675</wfw:commentRss><description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;After installing XP SP2 on the machine that runs my SQL Server, I found I could no longer access my SQL Server database from within the Visual Studio 2005 IDE or from any new applications created with Visual Studio 2005. Prior to installing SP2 the SQL Server was accessible and everything worked fine; now I get timeout errors from the SQL Server and my connection fails. &lt;span style="FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;L&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;&lt;/font&gt;&lt;span style="FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font face="Arial"&gt;What's going on here!! Why can’t I connect to the SQL Server on my Windows XP SP2 box?&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;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;It seems that installing SP2 automatically turns on the Windows Firewall, essentially cutting off communication to the SQL Server. When the Windows Firewall is enabled, it blocks communication to the SQL Server over TCP/IP, which is the primary protocol used by the .NET Framework Data Provider (System.Data.SqlClient.SqlConnection). When the SqlConnection tries to connect to the SQL Server over TCP/IP, the firewall blocks the connection, and the timeout error occurs.&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;strong&gt;&lt;font face="Arial"&gt;Well almost….&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;Strange thing is, I could still access the SQL Server from older versions of Visual Studio (2002 and 2003), as well as applications written with these versions?&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font face="Arial"&gt;So, why can I connect using Visual Studio 2003?&lt;o:p&gt;&lt;/o:p&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;Basically, applications written against ‘Version 1’ of the .Net Framework use &lt;i style="mso-bidi-font-style: normal"&gt;named pipes&lt;/i&gt; as the primary protocol when connecting to SQL Server. The firewall does not block communication using named pipes, and therefore allows the connection! Version 2 of the .NET Framework attempts to connect to the SQL Server using TCP/IP. Because the firewall is preventing communication over TCP/IP the connection fails, and the timeout error is raised.&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font face="Arial"&gt;&lt;/font&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font face="Arial"&gt;That's all nice to know - BUT HOW DO I FIX THE PROBLEM AND CONNECT TO MY SQL SERVER!!&lt;/font&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;You can do one of the following:&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-list: Ignore"&gt;1)&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;Modify settings on the client&lt;/i&gt;&lt;/b&gt; - You can adjust the connection string to use Named Pipes as the primary protocol. Do this by adding ‘np:’ (named pipes) in front of the SQL Server instance name. For example, if your SQL Server instance is named ‘SalesDatabase’ the connection string argument should be: ‘&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;Data Source=np:SalesDatabase&lt;/span&gt;&lt;/b&gt;’. This will force the connection into using named pipes as the primary protocol.&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;font face="Arial"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;You can&amp;nbsp;add the np: to the server name directly in the Server name box on the Add Connection dialog box. Change connections already saved in application settings by opening the Project Designer and editing the desired connection string setting.&amp;nbsp;For detailed instructions on editing connection strings in your application, see the &lt;/font&gt;&lt;a href="ms-help://MS.VSCC.v80/MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_raddata/html/a8dfe434-855d-4cec-8bc2-8a311c4eff1e.htm"&gt;&lt;font face="Arial"&gt;How to: Edit a Connection String&lt;/font&gt;&lt;/a&gt;&lt;font face="Arial"&gt;&amp;nbsp;topic in the Visual Studio help.&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;font face="Arial"&gt;-or-&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;font face="Arial"&gt;&lt;span style="mso-list: Ignore"&gt;2)&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;Modify settings on the SQL Server&lt;/i&gt;&lt;/b&gt; - If you can make changes on the machine that hosts the SQL Server you can adjust the settings of the firewall to allow communication with the SQL Server. Add the SQL Server (sqlserver.exe) as an exception to the firewall. This allows TCP/IP communication between clients and the SQL Server to bypass the Windows firewall. For detailed instructions on adding SQL Server as an exception to the firewall, see &lt;/font&gt;&lt;a href="http://support.microsoft.com/?kbid=841249"&gt;&lt;font face="Arial"&gt;http://support.microsoft.com/?kbid=841249&lt;/font&gt;&lt;/a&gt;&lt;font face="Arial"&gt;.&lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;After performing one of the above steps you should be able to access your SQL Server as expected! &lt;/font&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;-Steve&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;font face="Arial"&gt;&lt;/font&gt;&lt;/o:p&gt;&amp;nbsp;&lt;/p&gt; &lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;font face="Arial"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=404675" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Steve+Stein/default.aspx">Steve Stein</category></item></channel></rss>