none
I cannot connect to my basic SQL server from Visual Studio Ultimate 2013? Error 40 - Cannot establish connection

    Question

  • I just started learning ASP.NET through a book, and it asks to connect to "your" SQL server and explore a .mdf file. I've been trying to install SQL, but I only just now got a working installation, and even then it won't let me install the Management Software. Whenever I try to connect, I get this error: http://puu.sh/7F2JY.png

    This is exactly what I do to connect:

    1) Open project

    2) Navigate to the Server Explorer

    3) Click on connect to database

    4) In this menu, I can see me Machine name on the top part, which I think means that it's picking up my server runningh

    5) On the bottom, it wants me to enter a database name. I think this may be my problem, as I have no idea what to do here.

    Also, when I double click on the database file, I get this errpr (52): http://puu.sh/7F2Yw.png

    I really don't know what to do here, so post any tips down below


    Saturday, March 22, 2014 2:52 PM

Answers

  • Hi,

    Did you choose the correct Server name? It should be the machine name where you installed SQL Server on.

    Is it empty when you open select or enter database name drop box in the Add connect dialog box in the Visual Studio 2013?

    “Update: I re-installed, and then used both installers. Now I have the Server Management tools, but I still cannot connect.”

    The screenshots indicates that the SQL Server is not accessible.

    Do you mean that you are not able to connect SQL Server by using SQL Server Management Studio?

    If so, make sure that SQL Server Services is started.

    Please check out the following articles for details:

    How to: Start an Instance of SQL Server (SQL Server Configuration Manager)

    http://technet.microsoft.com/en-us/library/ms190699(v=sql.105).aspx

    Connect to Any SQL Server Component from SQL Server Management Studio

    http://technet.microsoft.com/en-us/library/ms173871.aspx

    Thanks.


    Tracy Cai
    TechNet Community Support

    Monday, March 24, 2014 8:24 AM
  • Hi Platinum,

    Please ensure your connection string is something like
        <connectionStrings>
            <add name="conn2" connectionString="Data Source=192.?.?.?\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 file in your project.


    Many Thanks & Best Regards, Hua Min

    Monday, March 24, 2014 8:29 AM
  • I thing you have an Express Edition of SQL Server, so try to use :

    .\SQLEXPRESS

    as a server name

    Monday, March 24, 2014 1:54 PM

All replies

  • Update: I re-installed, and then used both installers. Now I have the Server Management tools, but I still cannot connect. I'm using windows authentication, my machine name/my name.

    What I haven't done:

    -Opened any firewall ports

    -Done any configuration at all, I can't find anything to configure 

    Saturday, March 22, 2014 3:21 PM
  • Hi,

    Did you choose the correct Server name? It should be the machine name where you installed SQL Server on.

    Is it empty when you open select or enter database name drop box in the Add connect dialog box in the Visual Studio 2013?

    “Update: I re-installed, and then used both installers. Now I have the Server Management tools, but I still cannot connect.”

    The screenshots indicates that the SQL Server is not accessible.

    Do you mean that you are not able to connect SQL Server by using SQL Server Management Studio?

    If so, make sure that SQL Server Services is started.

    Please check out the following articles for details:

    How to: Start an Instance of SQL Server (SQL Server Configuration Manager)

    http://technet.microsoft.com/en-us/library/ms190699(v=sql.105).aspx

    Connect to Any SQL Server Component from SQL Server Management Studio

    http://technet.microsoft.com/en-us/library/ms173871.aspx

    Thanks.


    Tracy Cai
    TechNet Community Support

    Monday, March 24, 2014 8:24 AM
  • Hi Platinum,

    Please ensure your connection string is something like
        <connectionStrings>
            <add name="conn2" connectionString="Data Source=192.?.?.?\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 file in your project.


    Many Thanks & Best Regards, Hua Min

    Monday, March 24, 2014 8:29 AM
  • I thing you have an Express Edition of SQL Server, so try to use :

    .\SQLEXPRESS

    as a server name

    Monday, March 24, 2014 1:54 PM