locked
Visual Studio 2013 fails to connect to .mdf file RRS feed

  • Question

  • Hello,

    This is my 1st post and I'm new to development.  I'm attempting to connect to a database file through visual studio 2013 Ultimate.  The .mdf file is located on my local drive inside the App_Data folder of the project.  However when I try to connect to the file it fails and throws an error message (see below).   Can anyone help me out?

    “The attempt to attach to the database failed with the following information: 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. The specified LocalDB instance does not exist.”


    Thanks in advance,

    Ben

    • Moved by Jiayi Li Wednesday, October 21, 2015 6:39 AM
    Tuesday, October 20, 2015 3:21 PM

Answers

All replies

  • Hi B. Gray,

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Your issue would be related to SQL server, I help you move this case to                 
    SQL Server Express forum for dedicated support.

    Thank you for your understanding.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Wednesday, October 21, 2015 6:37 AM
  • Hi Ben,

    The above error message indicates that it cannot find LocalDB on your computer. Firstly, please make sure that you have installed SQL Server Express LocalDB on your machine.

    Secondly, if you have LocalDB installed, ensure that SQL Server Service is started, also check that if you can connect to SQL Server LocalDB via SQL Server Management Studio and attach database.

    Thirdly, check the connection string in Visual Studio.

    There are some similar articles for your reference.
    https://gerardbeckerleg.wordpress.com/2012/06/24/microsoft-visual-studio-2012-converting-database-to-localdb/
    http://social.technet.microsoft.com/wiki/contents/articles/4609.troubleshoot-sql-server-2012-express-localdb.aspx

    Thanks,
    Lydia Zhang

    If you have any feedback on our support, please click here.


    Lydia Zhang
    TechNet Community Support





    Wednesday, October 21, 2015 7:41 AM
  • EIther you dont have an installed SQLServer instance (express atleast) or the SQLServer service is not up and running.

    If former, please install an expresse edition for SQLServer

    For latter first check in SQL Server configuration manager or services.msc to see if SQLServer service is present. If yes check if its started. If not started, right click and start it.


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    Wednesday, October 21, 2015 7:50 AM
  • The specified LocalDB instance does not exist

    Hello Ben,

    Please check in Connection string the used LocalDB instance name and if that instance exists on your machine, otherwise create it, see SqlLocalDB Utility


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Wednesday, October 21, 2015 7:54 AM
  • Try to put this
    	<connectionStrings>
    		<add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
    	</connectionStrings>


    within Web.config/app.config file in your project, to ensure the project will work fine with the database.

    Many Thanks & Best Regards, Hua Min


    • Edited by Jackson_1990 Wednesday, October 21, 2015 11:17 AM
    Wednesday, October 21, 2015 11:16 AM
  • So the issue was my company computer wouldn't allow SQL on my computer.  Even though local DB was installed, a security policy was blocking the program somehow.  My resolution was to get a standalone laptop for development.

    Thank you Lydia!

    Tuesday, November 3, 2015 6:51 PM