【问题标题】:Incorrect syntax error when accessing remote stored procedure访问远程存储过程时语法错误
【发布时间】:2010-07-23 22:52:46
【问题描述】:

StackOverflow - 我仍在尝试部署此站点,但随着我解决的每一个问题,都会出现另一个问题。无论如何 - 我已经在我的主机上设置了数据库以允许远程连接,它正在运行 Sql Server 2005。在我的开发机器上,我正在使用 Sql Server 2008。

我已经在我的托管数据库上安装了 asp.net 架构,并从 ASP.NET Web 管理界面创建了几个用户,并测试了登录是否有效。使用远程连接字符串在本地运行应用程序会得到相同的结果。但是 - 我能够运行我的脚本并生成我的表和存储过程而不会出现错误 - 但是当网站运行时,我在尝试访问存储过程的所有 .aspx 页面上都收到以下错误:

Server Error in '/' Application.
Incorrect syntax near 'LoadProfileData'.
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: Incorrect syntax near 'LoadProfileData'.

Source Error:

Line 62:             adapter.SelectCommand.Parameters.Add("@ProfessionalName", SqlDbType.VarChar).Value = professionalName;
Line 63:             DataSet profile = new DataSet();
Line 64:             adapter.Fill(profile, "Profile");
Line 65:             return profile;
Line 66:         }

这可能是 Sql 2005 vs 2008 的问题吗?我希望其他人在类似的情况下也看到了这个问题,并能指出我正确的方向。服务器正在运行 asp.net 2.0、3.0 和 3.5 以及 IIS 7.0。

【问题讨论】:

    标签: sql-server-2005 sql-server-2008 asp.net sql


    【解决方案1】:

    认为我们真的需要查看 proc,您发布的消息表明这是一个语法错误,也许您在 proc 中使用了 sql2008 功能。 如果您在开发中运行 SQL 2008,请尝试将数据库兼容性级别设置为 9,看看是否会遇到相同的错误。

    【讨论】:

    • 嘿,感谢您的回答,但这是从服务器故障迁移而来的重复问题。我需要在 DAL 中的过程调用之前添加“exec”。
    猜你喜欢
    • 2018-05-12
    • 2011-04-18
    • 2012-04-12
    • 2014-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多