Impossible to connect to SQL Server 2005 Express

Discussion in 'ASP .Net' started by Gabriel, Mar 11, 2007.

  1. Gabriel

    Gabriel Guest

    Hello,

    I installed SQL server 2005 SP1 on a Windows XP SP2

    From Visual Studio, I'm trygin to create a connection to a database, but I
    receive this error but I'm creating the connection (I don't receive the
    database list in the dropdown)

    "An error has occured while establishing a connection to the server. When
    connecting to SQL Server 2005, this failure may be caused by the fact that
    under the default settings, SQL Server does not allow remote connections
    (provider : Named Pipes, error : 40 - Could not open a Connection to SQL
    Server)

    This time, I'm lost :
    - disabled firewall
    - Configration manager : TCP/IP and Named Pipes enabled
    - SQL NAtive Client Configuration : TCP/IP and Named Pipes are enabled
    - ServerManager : Security -> Login add MyComputerName\ASPNET

    But impossible to connect from Visual Studio 2005, no database in the
    dropdown.

    Any idea ?

    Regards,
     
    Gabriel, Mar 11, 2007
    #1
    1. Advertising

  2. Follow the instructions in this KB :

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Gabriel" <> wrote in message news:...
    > Hello,
    >
    > I installed SQL server 2005 SP1 on a Windows XP SP2
    >
    > From Visual Studio, I'm trygin to create a connection to a database, but I receive this error but
    > I'm creating the connection (I don't receive the database list in the dropdown)
    >
    > "An error has occured while establishing a connection to the server. When connecting to SQL Server
    > 2005, this failure may be caused by the fact that under the default settings, SQL Server does not
    > allow remote connections (provider : Named Pipes, error : 40 - Could not open a Connection to SQL
    > Server)
    >
    > This time, I'm lost :
    > - disabled firewall
    > - Configration manager : TCP/IP and Named Pipes enabled
    > - SQL NAtive Client Configuration : TCP/IP and Named Pipes are enabled
    > - ServerManager : Security -> Login add MyComputerName\ASPNET
    >
    > But impossible to connect from Visual Studio 2005, no database in the dropdown.
    >
    > Any idea ?
    >
    > Regards,
     
    Juan T. Llibre, Mar 11, 2007
    #2
    1. Advertising

  3. Gabriel

    Gabriel Guest

    Gabriel, Mar 11, 2007
    #3
  4. Gabriel

    James Irvine Guest

    Gabriel wrote:
    >> Follow the instructions in this KB :
    >> http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

    >
    > Thanks, but no change still impossible to connect from Visual Studio.
    >
    > Any other idea ?
    >
    > Regards,


    I had the exact same error and fixed it by adding \SQLEXPRESS to the
    connect string:


    Data Source=myHost\SQLEXPRESS;Initial Catalog=pMyLocalexpress;Integrated
    Security=True;Pooling=False
     
    James Irvine, Mar 11, 2007
    #4
  5. re:
    > Thanks, but no change still impossible to connect from Visual Studio.


    Did you stop/restart SQL Server 2005 ? A stop/restart is needed.

    Is SQL Server 2005 Express installed on the same box as Visual Studio ?
    You don't need to setup *Remote Access* to connect to a local SQL Server 2005.

    If it is installed on the same box, the connection should be quite easy :

    <configuration>
    <connectionStrings>
    <add name="MySqlServer" connectionString="Data Source=machinename\SQLEXPRESS;
    Initial Catalog=YourdbName;Integrated Security=True" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    </configuration>

    You also, of course, need to have a matching <providers> entry for "MySqlServer" in web.config.

    i.e., :
    <providers>
    <add connectionStringName="MySqlServer"
    .... etc.
    </providers>






    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Gabriel" <> wrote in message news:%...
    >
    >> Follow the instructions in this KB :
    >> http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

    >
    > Thanks, but no change still impossible to connect from Visual Studio.
    >
    > Any other idea ?
    >
    > Regards,
    >
     
    Juan T. Llibre, Mar 11, 2007
    #5
  6. Hi,

    Are you using SQL Server 2005 or SQL Express?? If you are using SQL Express
    edition you need to add Machinename\SQLESPRESS as the server name else the
    machine name alone will do. Is this error getting only while connecting from
    VS??



    --
    Web Programmer,
    Technopark, Thiruvanathapuram,
    India.


    "Juan T. Llibre" wrote:

    > re:
    > > Thanks, but no change still impossible to connect from Visual Studio.

    >
    > Did you stop/restart SQL Server 2005 ? A stop/restart is needed.
    >
    > Is SQL Server 2005 Express installed on the same box as Visual Studio ?
    > You don't need to setup *Remote Access* to connect to a local SQL Server 2005.
    >
    > If it is installed on the same box, the connection should be quite easy :
    >
    > <configuration>
    > <connectionStrings>
    > <add name="MySqlServer" connectionString="Data Source=machinename\SQLEXPRESS;
    > Initial Catalog=YourdbName;Integrated Security=True" providerName="System.Data.SqlClient"/>
    > </connectionStrings>
    > </configuration>
    >
    > You also, of course, need to have a matching <providers> entry for "MySqlServer" in web.config.
    >
    > i.e., :
    > <providers>
    > <add connectionStringName="MySqlServer"
    > .... etc.
    > </providers>
    >
    >
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "Gabriel" <> wrote in message news:%...
    > >
    > >> Follow the instructions in this KB :
    > >> http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

    > >
    > > Thanks, but no change still impossible to connect from Visual Studio.
    > >
    > > Any other idea ?
    > >
    > > Regards,
    > >

    >
    >
    >
    >
     
    =?Utf-8?B?UHJhbW9kIEt1bWFyIFQuVg==?=, Mar 12, 2007
    #6
  7. Gabriel

    Gabriel Guest


    > Are you using SQL Server 2005 or SQL Express?? If you are using SQL
    > Express
    > edition you need to add Machinename\SQLESPRESS as the server name else the
    > machine name alone will do. Is this error getting only while connecting
    > from
    > VS??


    It's the express edition, before on this PC it was the standard edition

    Listen ... I do this
    - Launch VS2005
    - File > New Web site .. I give a name
    - Server explorer > Add connection :

    With this parameter :
    - server name : localhost (tried : localhost\SQLESPRESS too)
    - SQL server authentification : username :sa and the password

    Nothing in the dropdown to select the database

    There is no web.config at this time. I add one, did the same operation, no
    difference.

    Regards,
     
    Gabriel, Mar 12, 2007
    #7
  8. Gabriel

    Gabriel Guest


    > I had the exact same error and fixed it by adding \SQLEXPRESS to the
    > connect string:


    You are right, I had : mycomputer\SQLEXPRESS in the wizard and that's work
    fine now

    Thank everybody
     
    Gabriel, Mar 12, 2007
    #8
  9. I hope that you are able to establish the connection from Management studio.

    If so follow these steps:

    1) Enable sql server browsing services

    1. Click Start, point to Programs, point to Microsoft SQL Server 2005,
    point to Configuration Tools, and then click SQL Server Surface Area
    Configuration.
    2. On the SQL Server 2005 Surface Area Configuration page, click
    Surface Area Configuration for Services and Connections.
    3. On the Surface Area Configuration for Services and Connections page,
    click SQL Server Browser, click Automatic for Startup type, and then click
    Apply.

    Note When you click the Automatic option, the SQL Server Browser service
    starts automatically every time that you start Microsoft Windows.
    4. Click Start, and then click OK.


    2) Launch VS2005
    - Server explorer > Add connection :

    You will get a pop up asking for choose datasource:

    select Data source as "Microsoft SQL server" and Data Provider as ".Net
    Framework Data Provider for SQLServer".

    Click continue.

    Note:Check the data source and data provider from the Add connection popup
    by clicking on the change button if you get the Add connection popup directly.

    You will get the Add connection Popup:

    In that server name dropdownlist click on the dropdown arrow to select
    server. (Or) enter the "127.0.0.1\sqlexpress" as server name.

    Select Windows authentication / sqlserver and click on the button "Test
    Connection". If the connection succeeds try to select the database and click
    ok. You should get the databse tree view in the server explorer.

    Hope this would help!!!

    Regards,

    Pramod,
    Web Programmer,
    Technopark, Thiruvanathapuram,
    India.


    "Gabriel" wrote:

    >
    > > Are you using SQL Server 2005 or SQL Express?? If you are using SQL
    > > Express
    > > edition you need to add Machinename\SQLESPRESS as the server name else the
    > > machine name alone will do. Is this error getting only while connecting
    > > from
    > > VS??

    >
    > It's the express edition, before on this PC it was the standard edition
    >
    > Listen ... I do this
    > - Launch VS2005
    > - File > New Web site .. I give a name
    > - Server explorer > Add connection :
    >
    > With this parameter :
    > - server name : localhost (tried : localhost\SQLESPRESS too)
    > - SQL server authentification : username :sa and the password
    >
    > Nothing in the dropdown to select the database
    >
    > There is no web.config at this time. I add one, did the same operation, no
    > difference.
    >
    > Regards,
    >
    >
    >
    >
     
    =?Utf-8?B?UHJhbW9kIEt1bWFyIFQuVg==?=, Mar 12, 2007
    #9
  10. re:
    > - server name : localhost (tried : localhost\SQLESPRESS too)


    That won't do.

    You *need* to use machinename\SQLEXPRESS

    re:
    > - SQL server authentification : username :sa and the password


    Try using mixed authentication.

    Windows Authentication mode is the default security mode
    after a typical installation of SQL Server 2000 or of SQL Server 2005.

    You cannot use a SQL Server Standard security login account after a Typical
    installation of SQL Server 2000/2005 until you change the authentication mode to Mixed.

    You can change the authentication mode manually by modifying
    the following registry information to contain value 2 instead of 1:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\LoginMode

    1 means Windows authentication, this is the value you should find set.
    By changing this to 2, you'll set the mixed authentication mode.

    Be sure to restart the server for this change to take effect.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Gabriel" <> wrote in message news:%...
    >
    >> Are you using SQL Server 2005 or SQL Express?? If you are using SQL Express
    >> edition you need to add Machinename\SQLESPRESS as the server name else the
    >> machine name alone will do. Is this error getting only while connecting from
    >> VS??

    >
    > It's the express edition, before on this PC it was the standard edition
    >
    > Listen ... I do this
    > - Launch VS2005
    > - File > New Web site .. I give a name
    > - Server explorer > Add connection :
    >
    > With this parameter :
    > - server name : localhost (tried : localhost\SQLESPRESS too)
    > - SQL server authentification : username :sa and the password
    >
    > Nothing in the dropdown to select the database
    >
    > There is no web.config at this time. I add one, did the same operation, no difference.
    >
    > Regards,
    >
    >
    >
     
    Juan T. Llibre, Mar 12, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    350
    farseer
    Aug 8, 2006
  2. Brad  Brening
    Replies:
    0
    Views:
    452
    Brad Brening
    Mar 1, 2007
  3. Jake Henderson

    Visual Web Developer 2005 Express and SQL 2005 Express

    Jake Henderson, Mar 10, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    234
    Jake Henderson
    Mar 10, 2006
  4. Wesley Chen
    Replies:
    0
    Views:
    227
    Wesley Chen
    Apr 7, 2009
  5. Wesley Chen
    Replies:
    9
    Views:
    244
    Sean O'Halpin
    Apr 14, 2009
Loading...

Share This Page