Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i want to make a test connection module for my application which test if the server is found on a particular IP with user name and password

some of our servers don't have password so it is just a user name

when i call the method to check the database connection this exception is released


An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)


i don't know why it contain SQL Server 2005 while i'm connecting to SQL Server 2000

and why it fails when i enters a connection string with no password although it connects on the query analyzer
example of the connection string
"packet size=4096;user id=sa;data source=xxx.xxx.xxx.xxx;persist security info=True;password=;initial catalog=DebitCardIssuance"

the function i'm using to test the connection


SqlConnection conn = new SqlConnection(connectionString);
            try
            {
                conn.Open();
                return true;
            }catch(Exception e)
            {
                return false;
            }


please advice
Posted
Updated 14-Sep-10 23:47pm
v2
Comments
Chris Maunder 15-Sep-10 21:45pm    
Please tell me you aren't leaving your sa password blank....

1 solution

It might be surface area configuration error or sql service configuration issue. Have a look at this thread for potential reasons and resolutions: Resolving A network-related or instance-specific error occurred while establishing a connection to SQL Server[^]

If needed, See steps for setting up Surface area configuration here..

If this does not resolve your issue, have a look at these thread:
http://forums.asp.net/t/1334649.aspx[^]
SQL SERVER FIX ERROR (provider: Named Pipes [^]
Quite few possible reasons and resolutions are proposed here too.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900