Reputation: 11712
When I run my website under local IIS instead of embedded IIS express I got the following error when accessing database (mdf file at app_data)
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Here the connection string:
Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Sources\Local\WebApplication1\WebApplication1\App_Data\aspnet-WebApplication1-20140226022052.mdf;Integrated Security=True
From Visual Studio and IIS Express I could connect to that database:
But the issue is that I need to have access to deployed application from another computer and IIS Express doesn't allow remote connections. That is why I was forced to use Local IIS.
Thank you for any advises!
Upvotes: 5
Views: 4221
Reputation: 182
There are couple of things to try:
Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=aspnet-WebApplication;Integrated Security=SSPI
<applicationPools>
..
<add name="MyAppPool" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>
..
<applicationPools>
Alternatively you could try changing Identity under App Pool Advanced Settings from ApplicationPoolIdentity to LocalSystem.
Upvotes: 0
Reputation: 1142
If you are using EntityFramework, try put it on App.config, worked for me.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
Upvotes: 0
Reputation: 36
you may need to double escape the \
"Data Source=(LocalDB)\v11.0;Integrated Security=true"
Upvotes: 2