2

I have looked all over and cannot seem to find the answer to this error:

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

I am writing an ASP.NET application from an empty web project and trying to add roles/membership to the application. I have made the login/logout pages myself but I am using the premade "login" tool. The DB I am using is my own DB instance "Accounts" which uses windows authentication. When I am in debug mode, I can login just fine! But when I push to my localhost, i get this error. Before I show all the code/stack trace/etc. let me list what ive done so far:

  1. I HAVE run the aspnet_regsql.exe multiple times from both the V4 and V2 folders just incase I missed anything (because all the help for this error I found was in V2)

  2. I have checked the application pool in IIS, I switched it from "applicationpoolidentity" to "network service" because I was getting this error while it was "applicationpoolidentity"

System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\DefaultAppPool'.

  1. I tried restarting my computer

  2. I tried uninstalling/reinstaling VS2012 and SQL Server 2008 R2

  3. I manipulated the web.config multiple times with no luck

  4. I checking the connection string

  5. I have tried starting the MSSQL services (both my own instance and SQLEXPRESS)

  6. I have tried restarting the site in IIS

I am out of ideas. So with all that said, here is the code/stack trace/etc.:

web.config:

<configuration>
  <connectionStrings>
    <remove name="AccountsConnectionString"/>
    <add name="AccountsConnectionString" connectionString="Data Source=development;Initial Catalog=Accounts;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <system.web>

    <authentication mode="Forms"/>

    <roleManager enabled="true" defaultProvider="SqlRoleProvider">
      <providers>
        <clear/>
        <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="AccountsConnectionString"  />
      </providers>
    </roleManager>

    <membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="1500">
      <providers>
        <remove name="SqlMembershipProvider"/>
        <add name="SqlMembershipProvider" 
             type="System.Web.Security.SqlMembershipProvider" 
             connectionStringName="AccountsConnectionString" 
             enablePasswordRetrieval="false" 
             enablePasswordReset="true" 
             requiresQuestionAndAnswer="false" 
             requiresUniqueEmail="false" 
             applicationName="ConsultDemo"
             minRequiredNonalphanumericCharacters="0"
             minRequiredPasswordLength="5"/>
      </providers>
    </membership>

    <profile enabled="true" defaultProvider="SqlProfileProvider">
      <providers>
        <clear/>
        <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="AccountsConnectionString" />
      </providers>
    </profile>

    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
</configuration>

Stack trace:

[SqlException (0x80131904): Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +388
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +688
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4403
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +6665097
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite) +6667096
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +577
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +735
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +290
   System.Web.Util.SecUtility.CheckSchemaVersion(ProviderBase provider, SqlConnection connection, String[] features, String version, Int32& schemaVersionCheck) +623
   System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +3888825
   System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +186
   System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +195
   System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +105
   System.Web.UI.WebControls.Login.AttemptLogin() +160
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +93
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +84
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

Picture to show the schema and stored procedure is infact in place:

Picture to show the schema and stored procedure is infact in place

Any help is appreciated! If there is an answer that I may have missed please point me to it. I am trying to get it to run on localhost...and nothing is working! Thank you all in advance.

Kevin Fauver
  • 561
  • 2
  • 8
  • 16

3 Answers3

1

Please provide UserID and Password to your connection string. Its not there in connection string.

The Hungry Dictator
  • 3,444
  • 5
  • 37
  • 53
1

Paraphrasing @RonakBhatt from the comments on the OP:

Even though you are using windows authentication, create a user using SQL authentication and add those credentials to the connection string.

Thank you @RonakBhatt for pointing that out. I figured one could still connect via windows authentication

Kevin Fauver
  • 561
  • 2
  • 8
  • 16
0

I have the same problem- i copy/paste connectionString from SQL Object manager in Visual Studio and forget to type Initial Catalog=YourDatabaseName.

Maxim Zhukov
  • 10,060
  • 5
  • 44
  • 88