0

我正在尝试运行一个存储过程,但我一生都无法克服这个错误。

如果我将 SQL 从存储过程中取出并将其放入硬编码的 ASP(经典)中,它可以 100% 工作,所以它不是代码。

我有大约 8 个其他类似的存储过程,它们工作正常,所以必须是特定于这个的,但似乎无法发现问题所在。

系统是旧的 Windows 2000 和 SQL Server 2000

错误:

用于 ODBC 驱动程序的 Microsoft OLE DB 提供程序 (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'lbg_UpdateUserRegInfo_ById' 需要未提供的参数 '@email_mananger'。
/inc/db_users.asp,第 316 行

实际存储过程代码

ALTER PROCEDURE [dbo].[lbg_UpdateUserRegInfo_ById]
    @id int,
@title nvarchar(10),
@firstname nvarchar(50),
@lastname nvarchar(50),
@jobtitle nvarchar(50),
@grade nvarchar(50),
@division nvarchar(50),
@department nvarchar(50),
@communitybank int,
@personalcontactnumber nvarchar(50),
@email nvarchar(75),
@linemanagerfirstname nvarchar(50),
@linemanagersurname nvarchar(50),
@groupmanagerfirstname nvarchar(50),
@groupmanagersurname nvarchar(50),
@seniorgroupmanagerfirstname nvarchar(50),
@seniorgroupmanagersurname nvarchar(50),
@email_mananger nvarchar(75),
@linked_manager_id int
AS
UPDATE lbg_userreginfo
SET
    [title] = @title, 
    [firstname] = @firstname, 
    [lastname] = @lastname, 
    [jobtitle] = @jobtitle, 
    [grade] = @grade, 
    [division] = @division, 
    [department] = @department, 
    [communitybank] = @communitybank, 
    [personalcontactnumber] = @personalcontactnumber, 
    [email] = @email, 
    [linemanagerfirstname] = @linemanagerfirstname, 
    [linemanagersurname] = @linemanagersurname, 
    [groupmanagerfirstname] = @groupmanagerfirstname, 
    [groupmanagersurname] = @groupmanagersurname, 
    [seniorgroupmanagerfirstname] = @seniorgroupmanagerfirstname, 
    [seniorgroupmanagersurname] = @seniorgroupmanagersurname , 
    [email_mananger] = @email_mananger,
    [linked_manager_id] = @linked_manager_id,
    [dt_modified] = GETDATE()
    WHERE [id_userreginfo] = @id

我正在使用的 CLASSIC ASP 代码/函数如下(arrayUserRegInfo 是一个 Dictionary 对象)

function db_UpdateUserRegInfo(ByRef arrayUserRegInfo)
    Dim cn, cmd, rs, userRegInfoID
    Set cn = Server.CreateObject("ADODB.Connection")
    cn.Open(strConnection)
    Set cmd = Server.CreateObject("ADODB.Command")
    Set cmd.ActiveConnection = cn
    Set rs = Server.CreateObject("ADODB.Recordset")        

    Dim sql
    sql = ""

    Dim manangerEmail
    manangerEmail = arrayUserRegInfo.Item("email_mananger")

    if(NOT arrayUserRegInfo.Count = 16)then
        cmd.CommandText = "lbg_UpdateUserRegInfo_ById"
        cmd.CommandType = adCmdStoredProc

        With cmd
            .Parameters.Append .CreateParameter("@id_userreginfo", adVarChar, adParamInput, 50)
            .Parameters("@id_userreginfo") = arrayUserRegInfo.Item("id_userreginfo")

            .Parameters.Append .CreateParameter("@title", adVarChar, adParamInput, 50)
            .Parameters("@title") = arrayUserRegInfo.Item("title")

            .Parameters.Append .CreateParameter("@firstname", adVarChar, adParamInput, 50)
            .Parameters("@firstname") = arrayUserRegInfo.Item("firstname")

            .Parameters.Append .CreateParameter("@lastname", adVarChar, adParamInput, 50)
            .Parameters("@lastname") = arrayUserRegInfo.Item("lastname")

            .Parameters.Append .CreateParameter("@jobtitle", adVarChar, adParamInput, 50)
            .Parameters("@jobtitle") = arrayUserRegInfo.Item("jobtitle")

            .Parameters.Append .CreateParameter("@grade", adVarChar, adParamInput, 50)
            .Parameters("@grade") = arrayUserRegInfo.Item("grade")

            .Parameters.Append .CreateParameter("@division", adVarChar, adParamInput, 50)
            .Parameters("@division") = arrayUserRegInfo.Item("division")

            .Parameters.Append .CreateParameter("@department", adVarChar, adParamInput, 50)
            .Parameters("@department") = arrayUserRegInfo.Item("department")

            .Parameters.Append .CreateParameter("@communitybank", adInteger, adParamInput, 4)
            .Parameters("@communitybank") = arrayUserRegInfo.Item("communitybank")

            .Parameters.Append .CreateParameter("@personalcontactnumber", adVarChar, adParamInput, 50)
            .Parameters("@personalcontactnumber") = arrayUserRegInfo.Item("personalcontactnumber")

            .Parameters.Append .CreateParameter("@email", adVarChar, adParamInput, 75)
            .Parameters("@email") = arrayUserRegInfo.Item("email")

            .Parameters.Append .CreateParameter("@linemanagerfirstname", adVarChar, adParamInput, 50)
            .Parameters("@linemanagerfirstname") = arrayUserRegInfo.Item("linemanagerfirstname")

            .Parameters.Append .CreateParameter("@linemanagersurname", adVarChar, adParamInput, 50)
            .Parameters("@linemanagersurname") = arrayUserRegInfo.Item("linemanagersurname")

            .Parameters.Append .CreateParameter("@groupmanagerfirstname", adVarChar, adParamInput, 50)
            .Parameters("@groupmanagerfirstname") = arrayUserRegInfo.Item("groupmanagerfirstname")

            .Parameters.Append .CreateParameter("@groupmanagersurname", adVarChar, adParamInput, 50)
            .Parameters("@groupmanagersurname") = arrayUserRegInfo.Item("groupmanagersurname")

            Call Debugging_OutputDictionObj(arrayUserRegInfo, "db_UpdateUserRegInfo->arrayUserRegInfo")

            .Parameters.Append .CreateParameter("@linked_manager_id", adInteger, adParamInput, 4)
            .Parameters("@linked_manager_id") = arrayUserRegInfo.Item("linked_manager_id")

            Response.Write "arrayUserRegInfo.Item(email_mananger) = " & arrayUserRegInfo.Item("email_mananger") & "<br>"

            .Parameters.Append .CreateParameter("@email_mananger", adVarChar, adParamInput, 75)
            .Parameters("@email_mananger") = manangerEmail

            .Execute
        End With
    else
        Response.Write "Error 008: Parameters missing<br>"
    end if

    cn.Close
    Set cn = Nothing
    Set cmd = Nothing
    Set rs = Nothing
    Response.End
    db_CreateUserRegInfo = userRegInfoID
end function
4

2 回答 2

1

您没有为@seniorgroupmanagerfirstnameor指定参数@seniorgroupmanagersurname

尝试添加这些参数并在代码中保持与存储过程声明中相同的顺序(您已交换了最后两个)。

于 2013-04-29T14:13:14.983 回答
1

如果您使用 SQL Server,请使用 SQL Profiler 查看实际发送到 SQL 的内容。通过这种方式,您可以查看是否缺少某些内容/拼写错误/其他内容。

在 .Net 中,如果变量为 null,即使您告诉它,它也不会添加参数。因此,您可能需要检查该字段是否确实具有值。

于 2013-05-02T15:18:01.050 回答