Connection string issues using (LocalDb)\v11.0 RRS feed

  • Question

  • User1953081067 posted


    I've been using Visual Studio 2013 Express to develop an ASP.NET MVC web application. When running in debug mode it loads just fine.

    I'd now like to run it directly from IIS (Windows 8.1). I've set it up fine, but it's not connecting to the same database (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred.)

    When running in debug mode from within VS2013, the connection string is:

    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\myDB.mdf;Initial Catalog=myDB;Integrated Security=True" providerName="System.Data.SqlClient" />

    This doesn't work when using IIS directly, so I changed it to this:

    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=myDB;Integrated Security=True; Trusted_Connection=Yes;MultipleActiveResultSets=true;" providerName="System.Data.SqlClient" />

    Which also doesn't work.

    I've installed MS SQL Management Studio and can connect fine to the DB. I've also tried changing the Catalog to myDB.mdf - still no joy.

    Any thoughts?

    Thanks as always

    Thursday, September 3, 2015 4:35 AM


  • User-166373564 posted


    To connect Local database, you can use connection string like below:

    <add name="ConnectionStringName"
        connectionString="Data Source=(LocalDB)\v11.0;AttachDbFileName=|DataDirectory|\DatabaseFileName.mdf;InitialCatalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True" />

    More information: https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx 

    Please let me know if you need any help.

    With regards,



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 4, 2015 1:32 AM