【问题标题】:Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'找不到存储过程“dbo.aspnet_CheckSchemaVersion”
【发布时间】:2011-01-11 01:48:59
【问题描述】:

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

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

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 

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

谢谢大家

贝尔

【问题讨论】:

  • 是否可能需要进一步限定存储的 proc 名称或所有者不是 dbo
  • 您使用的是什么版本的 SQL Server?

标签: sql sql-server stored-procedures


【解决方案1】:

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

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

【讨论】:

  • 谢谢 AdaTheDev。您能告诉我如何将电话更改为其他电话吗?比如,代码中的什么地方会是... web.config?
【解决方案2】:

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

  • 下载 http://download.microsoft.com/download/a/b/3/ab3c284b-dc9a-473d-b7e3-33bacfcc8e98/ProviderToolkitSamples.msi
  • 从源代码中替换所有 在您的主机中引用 dbo 数据库用户名
  • 编译(您需要 Visual Studio)和 将 ProviderToolkitSampleProviders.dll 中 Bin 文件夹
  • 在您的 web.config 中替换“类型” 每行的属性 “Microsoft.Samples., ProviderToolkitSampleProviders”
  • 将本地 sql server 中的所有 dbo 引用替换为您的托管数据库用户名
  • 导出sql对象创建脚本并在远程数据库上运行
  • 将本地 sql 表 aspnet_SchemaVersions 中的记录复制到远程数据库中

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

希望对你有帮助

托马斯

【讨论】:

  • 嗯?你世界的天空是什么颜色的?洛萨洛特。 Dude 只需要配置他的数据库或修复他的连接字符串。没有比这更好的答案了。
  • 糟糕,当他写道“我已正确执行所有步骤”时,我以为他已经尝试过 aspnet_regsql.exe 并仔细检查了连接字符串。我知道的托管服务提供商不允许使用 aspnet_regsql.exe,所以我的解决方案是适合这种情况的。
【解决方案3】:

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

  1. 使用 SQL Management Studio 或类似应用程序从本地 SQL Server 复制表、存储过程和视图
  2. 使用aspnet_regsql.exe tool 按照post 中的说明重新安装脚本(如果远程数据库被锁定,我不相信你可以使用该工具。所以你会必须导出脚本并手动运行它们)

【讨论】:

    【解决方案4】:

    您是否针对 WinHost.com 的 sql server 运行了aspnet_regsql.exe

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

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

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

    这个错误主要发生在你没有在你的 asp.net mvc 项目中启用 Roles 时在自动创建 aspnet 身份表之前启动。

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

    【讨论】:

    • 如果您已集成安全性,请使用“-E”标志而不是“-U”(用户名)和“-P”(密码)标志。
    • 谢谢!!!只是补充一下,你可以在没有命令行参数的情况下运行它来获得一个 GUI,不像 haxxor 但可以完成工作:)
    • @gabriel 如何运行aspnet_regsql.exe?
    • @IvorySantos:如果您询问可执行文件的常用路径,例如“%windir%\Microsoft.NET\Framework\v4.0.30319”。请参阅msdn.microsoft.com/en-us/library/ms229862.ASPX上的“查找正确版本的 Aspnet_regsql.exe”
    • 感谢@Gabriel 的帮助,非常感谢。
    【解决方案5】:

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

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

    【讨论】:

    • 嗨,伙计,运行 aspnet_regsql 我能够解决我的问题,现在问题是这个 --aspnet_regsql -- 做什么?
    【解决方案6】:

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

    【讨论】:

    • 我有 Initial Catalog=master 而不是 Initial Catalog=YourDatabaseName
    • 谢谢!这为我解决了问题。
    【解决方案7】:

    我在启用 <roleManager> 时遇到了完全相同的错误,我相信我正在启用 ASP.NET Identity 2。它们不一样!<roleManager> 启用了旧版本的身份管理它使用与 ASP.NET Identity 2 不同的表结构(顺便说一下,它不需要“启用” - 它就在那里)。

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

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

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

    【讨论】:

      【解决方案8】:

      最简单的解决办法是添加到web.config文件中

        <modules>
                <remove name="RoleManager" />
      
      </modules>
      

      【讨论】:

        【解决方案9】:

        正如Gabriel McAdams 所提到的,我使用了aspnet_regsql.exe,但是因为我在连接字符串中使用Integrated Security=True,所以我使用了不同的标志,并且还要注意-S 标志是指SQL Server 实例名称(在我的例子中是@ 987654324@) 而不是服务器名:

        C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regsql  -S DBInstanceName -E -A all -d DBName
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-01-26
          • 2011-07-10
          • 1970-01-01
          • 2015-09-24
          • 1970-01-01
          • 1970-01-01
          • 2010-10-25
          相关资源
          最近更新 更多