The same connection succeed and fails in different .net solutions

Total Post:341


 1613  View(s)
Rate this:
Hi Expert,

I have two .net solutions. They both have this code:

var connectionString = "Server = ServerName; Database = DatabaseName; Trusted_Connection=True;"
var connection = new SqlConnection(connectionString);

And they both use complitely the same connectionString. And they connect to MSSQL Server;

And in the first solution connection.Open() succeeded and in the second one it failed. Error message : Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

And every time I create new solution it fails. So this connection only works in one specific solution. And also, my teammates tested this and didn't have such issues.

Can you help with hints why it can be so?
  1. Re: The same connection succeed and fails in different .net solutions

    Hi Ankit,

    Open Sql Server Configuration Manager and make sure that the Named Pipes option is enabled for your Sql server instance.


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.