Could not open a connection to SQL Server

Discussion in 'Databases' started by Chimera, Oct 23, 2015.

  1. Hi!

    I've got an 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)

    My connection string is:
    <connectionStrings>
    <remove name="LocalSqlServer" />
    <add connectionString="Data Source=tcp:s10.winhost.com;Initial Catalog=DB_95113_logos;User ID=DB_95113_logos_user;Password=******;Integrated Security=False" name="LocalSqlServer" providerName="System.Data.SqlClient" />
    </connectionStrings>

    When I'm using Management Studio or the same connecting string in my local copy all works fine (remote connection from local Website to s10.winhost.com), but after publishing something goes wrong.

    I've read a lot of threads in this forum about pretty match the same issues, but nothing helps. I'm quite sure that I typed password right (because it's working on local Website).

    What did I do wrong?
     
  2. Elshadriel

    Elshadriel Winhost Staff

    Everything looks correct to me. Try recompiling your application in Visual Studio and re-deploying it.
     
  3. Hi!

    Of course, I tried to do that, but it didn't help. I have a main Website and Web API 2 application in it, and API application is trying to connect SQL. And one more thing I'm using logosres.w21.wh-2.com (secondary web url, not real domain, because the Website didn't finish yet )
     
  4. The clock is ticking, please, help!
     
  5. Hi, did you figure this out? It looks like your site is coming up at the alternate URL...
     
  6. Yes, I've found a problem.
    I have Website and Application (Web API) in it. API is using SQL (Entity Framework in separate assembly), but the same assembly is using in root Website (I'm using business objects from it) and in a mysterious way BO assembly in root a little bit different then assembly in API (using connection string from properties in the same time the assembly in API is using right connection string from Web.config).

    Probably it happened because of structure of my project. There are 2 separate projects (Website and API), which are using shared DB & BO assemblies. I should be more careful and more attentive in the future.

    Now all works fine, but every cloud has a silver lining, I've found thread about tag "location" in Web.config (<location path="." inheritInChildApplications="false">) which is made my life quite easier.
     
    ComputerMan, Michael and Elshadriel like this.

Share This Page