Failed to generate a user instance of SQL Server

Rate It (1)

Last post 09-27-2009 1:33 PM by opcode901. 9 replies.

Sort Posts:

  • Failed to generate a user instance of SQL Server

    01-28-2009, 5:55 PM
    • Member
      11 point Member
    • matejkralik
    • Member since 09-23-2008, 1:20 PM
    • Posts 40

     I am creating asp.net forms authentication. When I run web site and there I try to create new user I get this error:

    Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    SQLExpress database file auto-creation error:

    The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

    1. If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
    2. If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
    3. Sql Server Express must be installed on the machine.
    4. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.


    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [SqlException (0x80131904): Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.]
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846887
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
       System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
       System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +144
       System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
       System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
       System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
       System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +4861315
       System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +29
       System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +4863644
       System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
       System.Data.SqlClient.SqlConnection.Open() +122
       System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +82
    
    [HttpException (0x80004005): Unable to connect to SQL Server database.]
       System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString) +137
       System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install) +94
       System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString) +25
       System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) +395
    

     Could you please give me advice what to do?

    Mato
  • Re: Failed to generate a user instance of SQL Server

    04-03-2009, 11:31 PM
    • Member
      61 point Member
    • rudy1094
    • Member since 04-03-2009, 6:24 PM
    • Posts 35

     Foolish question, but do you have sql server installed on your machine?

  • Re: Failed to generate a user instance of SQL Server

    04-04-2009, 1:49 AM
    • Contributor
      2,926 point Contributor
    • PassHours
    • Member since 03-06-2006, 10:50 AM
    • India
    • Posts 471

    matejkralik:
    Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.
     

    you might need to delete the C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS directory. 

    Then restart ur machine.

    Hope that helps Yes

    Techie (.Net Knowledge at its Best)


    We make a living by what we get, but we make a life by what we give.
    ::: Winston Churchill :::
  • Re: Failed to generate a user instance of SQL Server

    04-04-2009, 2:29 PM
    • Member
      11 point Member
    • matejkralik
    • Member since 09-23-2008, 1:20 PM
    • Posts 40

    In the far meantime I solved this problem. I deleted sqlexpress directory, as mentioned above. But for this I logged as an administrator and in command prompt I got there...

    thanks anyway

    Mato
  • Re: Failed to generate a user instance of SQL Server

    06-03-2009, 7:05 AM
    • Member
      103 point Member
    • babuji_godem
    • Member since 11-20-2007, 11:59 AM
    • Hyderabad
    • Posts 51

     If you are using the membership provider and web parts, the connection string name should be LocalSqlServer

    Babuji Godem
    Human Logic Pvt Ltd.
  • Re: Failed to generate a user instance of SQL Server

    06-17-2009, 3:01 PM
    • Member
      8 point Member
    • ribald
    • Member since 10-11-2007, 3:57 PM
    • Posts 4
    Deleting the folder helped. Thank you!
  • Re: Failed to generate a user instance of SQL Server

    07-02-2009, 11:31 AM
    • Member
      74 point Member
    • Liste
    • Member since 11-27-2008, 2:33 PM
    • Posts 60

    Thanks for the help.  For those reading this forum and wanting to accomplish the same thing on Vista, delete this directory instead : C:\Users\username\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS

    Again, Thanks!

    Liste

  • Re: Failed to generate a user instance of SQL Server

    07-23-2009, 3:05 PM
    • Member
      2 point Member
    • TerryH99
    • Member since 07-23-2009, 7:01 PM
    • Posts 1

    Thanks so much for the help. I wrestled for ages with this - I think perhaps part of the problem was that I had downgraded from SQLExpress 2008 (although I had been having problems with that too).

    I found that for asp.net to create a user instance, I also had to delete:

    C:\Documents and Settings\<machine name>\ASPNET\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data.

    Hope this saves someone some pain!

  • Re: Failed to generate a user instance of SQL Server

    07-29-2009, 5:37 AM
    • Member
      2 point Member
    • suhakranthi
    • Member since 07-29-2009, 9:32 AM
    • Posts 1

    Thanks a lot.  I didn't had clue until i read ur article. I'm trying implement asp.net membership roles in sharepoint and got stuck with this error.

    I changed the connection string name to "localsqlserver" . It worked..

  • Re: Failed to generate a user instance of SQL Server

    09-27-2009, 1:33 PM
    • Member
      17 point Member
    • opcode901
    • Member since 02-05-2009, 3:24 PM
    • Posts 12

    I am having this same problem, and it seems that this forum is close to helping everyone find an answer.

    I am working on VISTA .x64 Ultimate SP2, with Visual Studio 2008 SP1 and I also have SQL Server (Express) 2008 installed. I upgraded from SQL Server Express 2005. In the SS Management Studio I can access all of the databases as required, including the problematic one called BOI_DB (BOI_DB.mdf), without any issues. I can also see all tables, sp etc., and edit any of them as desired, again without issues.

    In Visual Studio however, I cannot create new database files. When I right-click on my app's App_Data folder and choose "Add New Item...", then select Sql Server Database, I get an error message:

    "Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: ..."

    In addition to the above, when my ASP.NET 3.5 web app tries to add a record to this database, I get this error:

    "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed."

    and the app fails.

    I have tried many of the solutions displayed in this thread, but nothing seems to be working. Can someone please help me to find a solution to this frustrating problem. I've been on it for days and I am just not getting anywhere. Thanks for your help in advance.

    Best Regards,
    OpCode901

    You can sell your own property with a FREE For Sale By Owner Ad
Page 1 of 1 (10 items)