0

I'm trying to publish a website on IIS with localDB (SQL Server 2012/v11.0), but it gives me this 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: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.

On Visual Studio, it works well, but when it is published, it does this, all the time i access a page with a database embedded.

I modified the connections in the config file, I've added users into the access folder, modified parameter value, still nothing working.

There is my config file (all databases included are in the v11.0, i have v12.0 installed, as well):

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
  <appSettings />
  <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database1.mdf;Server=(LocalDB)\v11.0;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="connect" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database2.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation targetFramework="4.5" />
    <httpRuntime />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
        <authentication mode="Forms" />
        <identity impersonate="false" />
  </system.web>
</configuration> 

I'm using Windows authentication at the moment. Thank you in advance :)

system32
  • 15
  • 5
  • is it a proper sql server? in which case you should just get the db mounted on the server nd not try and attach, is it also under an instance called v11.0 ? it seems Im about the only person left using named instances these days – BugFinder Jul 16 '18 at 14:05
  • 1
    Did you look at the Windows event log, as the error message suggested? What did you see there? – mason Jul 16 '18 at 14:06
  • 1
    You cannot use LocalDB on an External IIS server. This is used for local testing / development. If you are publishing your application you should create a database on a SQL server and connect to it. Check the following link https://blogs.msdn.microsoft.com/gaurav/2013/12/21/deployment-of-sql-express-localdb-on-iis/ – Jordy van Eijk Jul 16 '18 at 14:08
  • "Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user." is one of the errors. The rest of them is like how i mentioned in the problem with the error 50 and "Windows API call SHGetKnownFolderPath returned error code: 5. Windows system error message is: Access is denied. Reported at line: 421. " – system32 Jul 16 '18 at 14:11
  • Actually, it was because of the IIS application setting xml: setProfileEnvironment = "false". Thank you very much, @JordyvanEijk! – system32 Jul 16 '18 at 14:24

0 Answers0