Sunday, September 16, 2007

Connecting to SQL 2005

Well, I've noticed a few things since converting my desktop to Vista and using SQL Server 2005...

First thing I noticed is that SQL 2005 does not like remote TCP connections. Instead, use Named Pipes by prefixing the server name/ip address with the prefix 'np:'.

Note: This does not appear to work with SQL 2000, so I have created an app setting in the App.Config file to set the database server type:



<configuration>
<appsettings>
<add value="localhost" key="QueueServerName">
<add value="localhost" key="CacheServerName">
<add value="SQL2005" key="DBType">
</appsettings>
</configuration>


Then, in the code, I use the ConfigurationManager as follows:

string dbType = ConfigurationManager.AppSettings["DBType"].ToString();

No comments: