Wednesday, April 13, 2005

My DotNet App is not Connecting to SQL Server 2000 after a change in IP address for SQL server...why?

There was heated exchange of mails in our company's internal knowledge Bulletin board.
One of my colleague was not able to make her ASP.net web app to run properly.

The SQL server 2000 Server IP address was changed, and after that the ASP.net application does not run.
The app runs fine if impersonated with the line identity impersonate =true is added to the web.config file, which was not the case before.

What might be the reason for this, after a long list of mails finally got the solution from a fellow employee in China.......

*********The Solution***********

The problem is caused by the IP address modification. Please follow the steps to locate the reason:
1. Login to the server where the SQL Server is deployed.

2. Execute SqlDiag.exe to gather information of the SQL Server.
By default, the SqlDiag.exe is under: C:\Program Files\Microsoft SQL Server\MSSQL\binn3. Open the log file generated by the SqlDiag.exe, check the IP address the SQL Server instance is listening.

By default there are three lines which are related with the IP address the SQL Server listen to. For example:

2005-03-30 14:38:36.65 server SQL server listening on 172.21.240.84: 1433.
2005-03-30 14:38:36.65 server SQL server listening on 127.0.0.1: 1433.
2005-03-30 14:38:36.68 server SQL server listening on TCP, Shared Memory, Named Pipes.

In above example, the first line is the IP address of the Server, the second is the lookback ip address, and these two are used to support TCP/IP connection to SQL Server. The third is for named pipeline protocol, which is defaulted enabled.

4. For your problem, mostly is because the SQL Server is still listening to the old IP address. Because the IP address has been changed, and SQL Server’s configuration is not changed, the client can not connect to SQL Server via TCP/IP protocol anymore.

5. If the problem can be located in step 4, the reason that why does the SQL Server can be connected while the “” is configured will be clear.
It’s because that the client application first selects TCP/IP to connect to the SQL Server.
If it is failed, the client application will try to use named pipeline. For named pipeline, it requires authentication before connecting. So, without the line in the Web.Config file, the link via named pipeline can not be established.
So, the client can not access SQL Server

Finally the fight is over........................

No comments: