Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I working on ASP.Net and try to connect to SQL Server 2005, but i am getting below error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Please tell me the solution.

Thanks,


Jhons
Posted

What does the error say ? What have you done to ensure that the error message is not correct ? Why do you think that telling us the error will result in us telling you how to fix a problem that relates to your code and your network setup, neither of which you have shared ?
 
Share this answer
 
if you are writing the connection in web.config file. Then you might have missed the PROVIDERNAME="System.Data.SqlClient"

XML
<connectionStrings>
        <add name="NorthConnection" connectionString="server=10.0.3.41;uid=sa;pwd=change_123;database=Northwind" providerName ="System.Data.SqlClient"/>
        
    </connectionStrings>
 
Share this answer
 
Comments
jhonrsa 14-Jul-10 15:35pm    
Thanks sainath,i given the providername in connection string. Its connecting now.
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
 
Comments
jhonrsa 14-Jul-10 15:38pm    
Thanks Sandeep, i changed the connection string settings and gothrough all the threads that you mentioned above,now i can connect to SQL Server.
Check if the Database server is up and running.
 
Share this answer
 
Comments
jhonrsa 14-Jul-10 15:39pm    
Database Server is Fine, I did changes on Connection String and followed the above threads,its help me to connect to SQL Server. Thanks...!
Hi Christian Graus,

Thanks for your mail.
Actually when I debugging iam getting an exception "SqlException was unhandled by user code", below its giving

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"

I try to enabled the Named Pipes and TCP/IP things in Sql Server 2005 Network Configuration.
I restarted the Server again and again, still getting the same exception. Do I need to change any settings in my settings. I am using Windows Vista Operating System.

Thanks,

Jhons
 
Share this answer
 
Comments
Christian Graus 13-Jul-10 17:46pm    
Please don't push answer if you're not posting an answer. Post a comment or edit your post.

Is it possible a firewall is blocking the connection ? Or perhaps that your connection string is wrong ?
Siva Kishore G 14-Jul-10 0:58am    
Hi jhonsra,
Inorder to connect to sql server database,we have to use "System.Data.SqlClient" provider.In ur case by default its taking Namedpipe provider.So change it to SqlClient Provider.
Sandeep Mewara 14-Jul-10 1:38am    
Reason for my vote of 1
Not an answer.

Use 'Improve Question' to edit/update it or use 'Add Comment' to respond to an answer.
jhonrsa 14-Jul-10 15:41pm    
Thanks Siva, After adding the provider name in connection string its working fine.

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