THE SAME CONNECTION SUCCEED AND FAILS IN DIFFERENT .NET SOLUTIONS

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 1100  View(s)
Ratings:
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);
connection.Open();
connection.Close();

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. Sumit Kesarwani

    Post:378

    Points:2694
    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!