views:

556

answers:

3

My company is currently migrating some of their really old db's to sql server 2005. Some legacy apps have problems connecting to the new server. The connection string works in Asp.NET 2.0, probably because it assumes tcp:1433 automatically.

I have to construct the connection string like this in ASP.NET 1.1 for it to work:

"Server=tcp:my.server.com,1433;..."

Without the protocol and the port, the connection fails ("Invalid Connection exception")

TCP 1433 and UDP 1434 are open on our firewall. On SQL Server 2005 Remote Access is enabled, so is TCPIP, the SQL Browser service is running, I use the proper login credentials.

Any ideas why I can't just specify the server name without protocol and port number?

A: 

Perhaps your SQL Server is configured for multi-protocol, and it's trying to use the other protocol first and failing, perhaps for some security reason (the account that the app is running as in IIS). Just a guess.

GeekyMonkey
+1  A: 

IIRC SQL Server 2005 defaults to find any-old-port that is available. On my laptop this means port 1212.

To force it to a specific port you must go to Start->Programs->SQL Server 2005->Configuration Tools->SQL Server Configuration Manager

From here you must go to SQL Server 2005 Network Configuration->Protocols for (name of service)->Right click on TCP/IP->Properties->Choose tab "IP Address" and set TCP Dynamic Ports to .

For some reason "0" means "Yes, use dynamic ports" and (i.e. no entry in field) menas "No, I will specify it myself"

Then fill in the field TCP Port with 1433.

Do so on all adapters that are listed, and restart the SQL Service.

You can now check if the service is indeed on the right port by doing the following

Start->Run->cmd.exe

C:>netstat -ano

look for an entry like this

 local address         <stuff>           PID
 0.0.0.0:1433                            <some number>

Now do C:>tasklist

and look for the task with the number from above. This task should be called something like sqlsrvr.exe.

Soraz
Already checked my TCPIP settings, it listens to 1433. Thanks tho.
kitsune
A: 

Check the "SQL Native Client Configuration" settings in "SQL Configuration Manager" on the ASP.NET machine. The default connection settings are set there. Also try messing with the MDAC configuration:

http://msdn.microsoft.com/en-us/library/ms131035.aspx

Robert Wagner