SQL 找不到存储过程“dbo.aspnet_CheckSchemaVersion”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2165908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 05:14:20  来源:igfitidea点击:

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'

sqlsql-serverstored-procedures

提问by jay_t55

I am using WinHost.com to host my site. The SQL Database/membership system works perfectly on my local computer, but when uploaded to the server it doesn't work. I've followed all steps correctly. And I have contacted support for my service but it's been over 2weeks and no reply.

我正在使用 WinHost.com 来托管我的网站。SQL 数据库/会员系统在我的本地计算机上运行良好,但是当上传到服务器时它不起作用。我已正确执行所有步骤。我已经联系了我的服务支持,但已经超过 2 周了,但没有回复。

I keep getting this error when i try to login or register a new user on my membership page on my site.

当我尝试在我网站的会员页面上登录或注册新用户时,我不断收到此错误。

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'. 
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. 

Exception Details: System.Data.SqlClient.SqlException: Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

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): Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1953274
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849707
   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.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +204
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137
   System.Web.Util.SecUtility.CheckSchemaVersion(ProviderBase provider, SqlConnection connection, String[] features, String version, Int32& schemaVersionCheck) +378
   System.Web.Security.SqlMembershipProvider.CheckSchemaVersion(SqlConnection connection) +89
   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) +815
   System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105
   System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42
   System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +78
   System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119
   System.Web.UI.WebControls.Login.AttemptLogin() +115
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016 

Can somebody please tell me why this error has occured (obviously it can't find something...), and how I can fix it?

有人可以告诉我为什么会发生这个错误(显然它找不到东西......),以及我如何解决它?

Thank you all

谢谢你们

Bael

贝尔

回答by Gabriel McAdams

Did you run aspnet_regsql.exeagainst WinHost.com's sql server?

您是否运行过aspnet_regsql.exeWinHost.com 的 sql 服务器?

aspnet_regsql.exe -S DBServerName -U DBLogin -P DBPassword -A all -d DBName

If you don't know where to run above command then you can simply run 'aspnet_regsql.exe' executable file.

如果您不知道在哪里运行上面的命令,那么您可以简单地运行“aspnet_regsql.exe”可执行文件。

In order to locate this file open your RUN Command Box by pressing Windows Key + r and put below command in that %windir%\Microsoft.NET\Framework\v4.0.30319and Hit enter then find 'aspnet_regsql.exe' file. It will open a wizard that you can follow to resolve this error.

为了找到此文件,请按 Windows 键 + r 打开 RUN 命令框,%windir%\Microsoft.NET\Framework\v4.0.30319然后在其中输入以下命令,然后按 Enter 键,然后找到“aspnet_regsql.exe”文件。它将打开一个向导,您可以按照该向导解决此错误。

This error mostly occurs when you didn't enabled Roles in your asp.net mvc project At starting before aspnet identity table automatically created.

这个错误主要发生在你没有在 asp.net mvc 项目中启用角色时在自动创建 aspnet 标识表之前开始。

You will need to make sure you run this so that the tables and objects are created on WinHost.com's SQL server.

您需要确保运行此程序,以便在 WinHost.com 的 SQL 服务器上创建表和对象。

回答by Nitin Sawant

Open visual studio command prompt from the Visual studio tools folder from the start menu and type aspnet_regsql

从开始菜单的 Visual Studio 工具文件夹中打开 Visual Studio 命令提示符并键入 aspnet_regsql

and follow the wizard to register the database for asp.net membership and role providers.

并按照向导为 asp.net 成员资格和角色提供程序注册数据库。

回答by Naeem Sarfraz

I've seen this before. The database you are using doesn't have the required database elements for the membership, role management and profile features. So you've got a couple of options:

我以前见过这个。您使用的数据库没有成员资格、角色管理和配置文件功能所需的数据库元素。所以你有几个选择:

  1. Copy across the tables, stored procedures & views from your local SQL Server using SQL Management Studio or a similar application
  2. Use the aspnet_regsql.exe toolto install the scripts from anew as per the instructions in this post(I don't believe you can use the tool against a remote database if it's locked down. So you'll have to export the scripts and run them manually)
  1. 使用 SQL Management Studio 或类似应用程序从本地 SQL Server 跨表、存储过程和视图复制
  2. 使用aspnet_regsql.exe 工具按照这篇文章中的说明重新安装脚本(我不相信如果远程数据库被锁定,您可以对该工具使用该工具。因此您必须导出脚本并运行他们手动)

回答by Maxim Zhukov

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

我有同样的问题 - 我从SQL Object managerVisual Studio 中复制/粘贴 connectionString并忘记输入Initial Catalog=YourDatabaseName.

回答by noelicus

I had the exact same error when I had enabled <roleManager>believing I was enabling ASP.NET Identity 2. They are not the same!The <roleManager>enabled an old version of identity management which uses a different table structure to ASP.NET Identity 2 (which doesn't need "enabling" by the way - it's just there).

当我<roleManager>相信我正在启用 ASP.NET Identity 2时,我遇到了完全相同的错误。它们不一样!<roleManager>启用旧版本的身份管理,它使用一个不同的表结构ASP.NET身份2(这并不需要的方式“有利” -它只是在那里)。

If you are intentionally using the old role-manager and still getting the error you might be looking at the default localdbinstead of your database, in which case you can modify <roleManager>to point at any connection string you want:

如果您有意使用旧的角色管理器并且仍然收到错误,您可能正在查看默认值localdb而不是您的数据库,在这种情况下,您可以修改<roleManager>以指向您想要的任何连接字符串:

  <roleManager
      enabled="true"
      cacheRolesInCookie="true"
      defaultProvider="OurSqlRoleProvider"
     >
      <providers>
          <add
             connectionStringName="DefaultConnection"
             applicationName="/"
             name="OurSqlRoleProvider"
             type="System.Web.Security.SqlRoleProvider" />
      </providers>

  </roleManager>

If you are are after using ASP.NET Identity 2, here's an article on it:
http://johnatten.com/2014/04/20/asp-net-mvc-and-identity-2-0-understanding-the-basics/

如果您正在使用 ASP.NET Identity 2,这里有一篇关于它的文章:http:
//johnatten.com/2014/04/20/asp-net-mvc-and-identity-2-0-understanding-the-基本/

回答by AdaTheDev

Check the schema the stored procedure belongs to on your host - it could be that it's not in the "dbo" schema.

检查存储过程在您的主机上所属的架构 - 可能它不在“dbo”架构中。

e.g. if it's within SomeOtherSchema, your call would need to be "SomeOtherSchema.aspnet_CheckSchemaVersion"

例如,如果它在 SomeOtherSchema 中,您的调用将需要是“SomeOtherSchema.aspnet_CheckSchemaVersion”

回答by Thomas

In short you should recompile the aspnet provider dll using the sql username you were assigned from your hosting.

简而言之,您应该使用从主机分配的 sql 用户名重新编译 aspnet 提供程序 dll。

  • Download the http://download.microsoft.com/download/a/b/3/ab3c284b-dc9a-473d-b7e3-33bacfcc8e98/ProviderToolkitSamples.msi
  • Replace from the source code all the references to dbo with your hosting database username
  • Compile (you need Visual Studio) and place the ProviderToolkitSampleProviders.dll in the Bin folder
  • In your web.config replace the "type" attribute of every line with “Microsoft.Samples., ProviderToolkitSampleProviders”
  • Replace in you local sql server all dbo references with your hosting database username
  • Export the sql object creation script and run them on the remote database
  • Copy the records from your local sql table aspnet_SchemaVersions to the remote database
  • 下载 http://download.microsoft.com/download/a/b/3/ab3c284b-dc9a-473d-b7e3-33bacfcc8e98/ProviderToolkitSamples.msi
  • 将源代码中对 dbo 的所有引用替换为您的托管数据库用户名
  • 编译(需要 Visual Studio),将 ProviderToolkitSampleProviders.dll 放在 Bin 文件夹中
  • 在您的 web.config 中,将每一行的“type”属性替换为“Microsoft.Samples., ProviderToolkitSampleProviders”
  • 将本地 sql 服务器中的所有 dbo 引用替换为您的托管数据库用户名
  • 导出sql对象创建脚本并在远程数据库上运行
  • 将本地sql表aspnet_SchemaVersions中的记录复制到远程数据库

Another option, pheraps simpler to try, is to replace the dbo references in your local sql server database with your hosting database username, then upload and attach your mdf file.

另一种选择,pheraps 更容易尝试,是将本地 sql server 数据库中的 dbo 引用替换为您的托管数据库用户名,然后上传并附加您的 mdf 文件。

Hope it helps

希望能帮助到你

Thomas

托马斯