none
Unable to connect to SQL Server database. using the ASPNET_REGSQL.EXE RRS feed

  • Question

  • Setup failed.

    Exception:
    Unable to connect to SQL Server database.

    ----------------------------------------
    Details of failure
    ----------------------------------------

    System.Web.HttpException: Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException: An error has occurred 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 Provider, error: 40 - Could not open a connection to SQL Server)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
       --- End of inner exception stack trace ---
       at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
       at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install)
       at System.Web.Management.SqlServices.Install(String database, SqlFeatures features, String connectionString)
       at System.Web.Management.ConfirmPanel.Execute()

    Wednesday, October 31, 2007 3:05 AM

All replies

  • What exactly do you do? Which edition of SQL Server do you have installed? Is it installed locally or on a network?

     

    Wednesday, October 31, 2007 10:46 AM
    Moderator
  • I am assuming you are using either the developer or Express edition which comes with most features disabled.  The steps below will take you in the right direction

     


    Steps for Configuration Manager:

    Make Browser service automatic from Manual in SQL Server 2005 services

     

    Go to Network Configuration in Configuration Manager

    Enable TCP/IP

    Enable Named Pipes

     

    Surface Area Configuration tool steps:

    Go to Surface Area configuration for services and Connection

    In Database Engine click on Remote Connection

    In there change to Local and Remote

    And choose both TCP/IP and Named Pipes it is the last option.

     

     

    If you do the above and still get an error then it maybe firewall related and that is covered by Microsoft below.

     

    http://support.microsoft.com/kb/914277

     

    When you have cleaned up the error 40 go to the location below in your C drive and run aspnet_regsql and create the ASPNETDB and use the tutorial in the link below to create the Asp.net membership. I use the developer edition and I have the aspnetdb running.  If you are still having problem send me an email I will send you the .bak.   Hope this helps.

     

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

     

    http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

     


     

     

     

    Wednesday, October 31, 2007 11:40 AM
  • I installed the Visual Studio 2005 on a Windows 2003 server w/ Service pack 1, but upon finishing of the installation there was an error saying that the SQL Server Express Edition failed to install so I reinstalled the SQL Server Express and it installed properly now after installing it I tried running ASPNET_REGSQL to connect to the Visual Studio and that was the error that I recieved.I have just installed it locally.
    Wednesday, November 7, 2007 1:49 AM
  • If it is SQL Express then make sure you have specified default named instance of it (SQLEXPRESS) in your connection string, otherwise you should expect that error. In a case of local server it should be like

     

    Server=.\SQLEXPRESS;Database=......

    Thursday, November 8, 2007 11:12 AM
    Moderator
  • But why is it that when I intall the Visual Studio 2005 on a Win XP Pro. w/ SP 2 it doesn't encounter that problem?Because what I'm trying to use is the built-in "login" control in ASP.Net toolbox and administer it's security.

    Friday, November 9, 2007 2:16 AM
  •  

    I follow the steps that you described above,but there is still a mistake error 40 and it is unable to set up membership database. Can you help me to solve the problem,please? Thank you!

     

    Setup failed.

    Exception:
    Unable to connect to SQL Server database.

    ----------------------------------------
    Details of failure
    ----------------------------------------

    System.Web.HttpException: Unable to connect to SQL Server database. ---> System.Data.SqlClient.SqlException: An error has occurred 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 Provider, error: 40 - Could not open a connection to SQL Server)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
       --- End of inner exception stack trace ---
       at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
       at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install)
       at System.Web.Management.SqlServices.Install(String database, SqlFeatures features, String connectionString)
       at System.Web.Management.ConfirmPanel.Execute()

    Wednesday, November 14, 2007 10:34 AM
  • In Win2003 your IIS 6 installation may not be correct so do all the configurations I gave you and also run aspnet_regiis.  The reason IIS 6 come locked down to render only static html you need to click on show details during installation and enable all the components needed to run Asp.net.

     

    Thursday, November 15, 2007 4:29 AM
  • If your configuration is correct then follow he steps in the link below and make sure not to change the connection string it is default used by the ASPNET application service.

     

    http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

     

    Thursday, November 15, 2007 4:33 AM
  • Could you please explain further or be more elaborate on the step 1 that you provided? thanx!

    Step 1: Create or obtain a blank SQL database instance

     

    In this step you’ll want to create or obtain a connection string to a standard SQL database instance that is empty.

     

    Thursday, November 22, 2007 5:58 AM
  • Please Make Changes On Configuration. for deatil Read MSDN Documents.

    hint

    if you are not able to connect ASPNETREGSQL.EXE this may cause of authentication

    please get help

    ASPNETREGSQL/?

    Make changes on configuration provider section and gine connection string with user name password.

    Friday, November 23, 2007 6:06 AM
  • That is not correct because the only thing you do is run the aspnet_regsql utility and add the required default connection string which is in the link I posted.  Then you can use the Web Admin wizard.  Here is a video if you still have questions after the video you may need a class.  Why because there are only two steps run aspnet_regsql and add connection string.

     

    http://www.asp.net/learn/videos/video-148.aspx

     

    Tuesday, November 27, 2007 7:31 PM
  • I tried everything that about 3 forums suggested and have done everything that microsoft provided.  I am still getting the 40 error... Running on Windows Vista using Express Edition.

    PLEASE HELP!
    Friday, February 13, 2009 9:44 AM
  • This is an add on to a closed thread you need to split it instead of giving none relevant answers because Vista with SQL Server Express issues are related to none admin permissions use in Vista.


    MCPD Web C#, MCTS TFS, MCITP BI and DBA
    Friday, February 13, 2009 11:48 PM
  • Had the same problem and ws revolving from 1 forum to another. Then i caught the problem which i think ws very trivial.

    While in the aspnet_regsql.exe

    It asks for a server: ABC

    In this box it had my default machine ABC name coming. All i did ws changed this to the one it shows in the SQL server management studio(ABC/SERVER_A)

    Though i have a slight feeling that you must have either got the solution or given up on it....its been 3 yrs!!

    Friday, July 2, 2010 9:22 AM
  • omgdns nitcoolish I was struggling with this for a few hours and never realised aspnet_regsql.exe was indeed using the computer name while the actual SERVER NAME is what should be used. tks
    Sunday, June 26, 2016 9:40 PM