[Microsoft] [ODBC SQL Server驱动程序] [SQL Server]“ @ errno”附近的语法不正确

时间:2018-08-21 06:50:47

标签: sql-server asp-classic odbc

我们有一个经典的ASP页面,该页面使用ODBC SQL Server驱动程序与SQL Server 2000进行交互。数据库团队将该实例移至SQL Server2014。现在,我们有了一个不使用RAISEERROR @error语法的过程,但仍然在相同的过程中得到以下错误:

  

错误编号=(-2147217900)
  错误说明:[Microsoft] [ODBC SQL Server驱动程序] [SQL Server]'@ errno'附近的语法不正确。
  错误源:用于ODBC驱动程序的Microsoft OLE DB提供程序

我在.asp代码中签入@errno未被使用。这只是一个简单的INSERT语句。

有人可以帮助我知道错误是什么吗?该应用程序托管在Windows 2003计算机上。我是否应该更新ODBC驱动程序,以便它与SQL Server 2014正确通信。这是一个选择吗?

当我搜索错误号时,我没有完全匹配,但是对于某些其他错误,没有解决方法是将“兼容模式”设置为80。这样可以消除错误吗?

ASP代码:

sub subPutValueIntoReport_Table (sBenefit, sCategory, sFiscal, sReport, sLine, fAmt, sCalendar)
    dim sProc, oRS
    sProc = "spReport_Table 'SELECT_AMOUNT'"
    sProc = sProc & ", '" & sBenefit & "'"
    sProc = sProc & ", '" & sCategory & "'"
    sProc = sProc & ", '" & sFiscal & "'"
    sProc = sProc & ", '" & sReport & "'"
    sProc = sProc & ", '" & sLine & "'"
    dbExecuteSqlRS oRS, sProc

    'If the record does not exist, insert the record, else update the record
    if oRS.bof and oRS.eof then
        sProc = "spReport_Table 'INSERT'"
    else
        if "1" & oRS(0) & "1" = "11" then
            sProc = "spReport_Table 'INSERT'"
        else
            sProc = "spReport_Table 'UPDATE'"
        end if
    end if

    oRS.close
    set oRS = nothing
    sProc = sProc & ", '" & sBenefit & "'"
    sProc = sProc & ", '" & sCategory & "'"
    sProc = sProc & ", '" & sFiscal & "'"
    sProc = sProc & ", '" & sReport & "'"
    sProc = sProc & ", '" & sLine & "'"
    sProc = sProc & "," & fAmt
    sProc = sProc & ", '" & sCalendar & "'"
    sProc = sProc & ", '" & session("userid") & "'"

    if session("debug") then Response.Write "<br>" & sProc & "<br>"

    dbExecuteSql sProc
end sub

SP我无法提供完整的SP详细信息,将删除一些重要的详细信息,例如表名和注释:

CREATE PROCEDURE spReport_Table  
 @query_type varchar(20),  
 @benefit_code varchar(4),  
 @category_code varchar(4),  
 @fiscal_period char(6),  
 @report_name varchar(40),  
 @line_desc varchar(40),  
 @line_amt decimal (20, 2) = 0,  
 @cal_period varchar(6) = '000000',  
 @uid varchar(20) = 'xProc'  

AS  

/*-- define variables */  
DECLARE @sSql AS NVARCHAR(2000)  

IF UPPER(@query_type) = 'SELECT_AMOUNT'  
 BEGIN  
  SET @sSql = "SELECT sum(Line_Amt) "  
  SET @sSql = @sSql + "FROM table "  
  SET @sSql = @sSql + "WHERE column_name1 in (" + @benefit_code  + ") "  
  SET @sSql = @sSql + "AND column_name2 = '" + @category_code + "' "  
  SET @sSql = @sSql + "AND column_name3 = '" + @fiscal_period + "' "  
  SET @sSql = @sSql + "AND column_name4 = '" + @report_name + "' "  
  SET @sSql = @sSql + "AND column_name5 = '" + @line_desc + "' "  

  EXEC  sp_executesql @sSql  
 END  

ELSE IF UPPER(@query_type) ='INSERT'  
 INSERT INTO Table (column_names)   
 VALUES (values)  

ELSE IF UPPER(@query_type) ='UPDATE'  
 UPDATE Table  
 SET colum_names=values  

ELSE IF UPPER(@query_type) ='DELETE'  
 DELETE FROM Table   
 WHERE Condition

0 个答案:

没有答案