如何解决以下问题?储存程序

时间:2019-01-09 18:32:08

标签: asp.net sql-server stored-procedures

当我执行下面的存储过程时,它将在我的网页中导致错误。错误是

  

过程或函数'AuditsReportForLPA'需要参数'@Division',但未提供

这是asp.net标记:

<asp:SqlDataSource ID="sqlAudits" runat="server" 
     ConnectionString="<%$ ConnectionStrings:TESTQTYConnectionString %>"
     SelectCommand="AuditsReportForLPA" SelectCommandType="StoredProcedure">
     <SelectParameters>
            <asp:ControlParameter ControlID="ddlAuditType" Name="AuditType" 
                PropertyName="SelectedValue"/>
            <asp:ControlParameter ControlID="ddlDivision" Name="Divison" 
                PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="txtDateFrom" Name="dateFrom" 
                PropertyName="Text" />
            <asp:ControlParameter ControlID="txtDateTo" Name="dateTo" PropertyName="Text" />
            <asp:ControlParameter ControlID="ddlAuditedBy" Name="name" 
                PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>

这是我的存储过程

ALTER PROCEDURE [dbo].[AuditsReportForLPA]
    @AuditType NVARCHAR(75),
    @Division NVARCHAR(10),
    @dateFrom DATETIME,
    @dateTo DATETIME,
    @name VARCHAR(14)
AS
BEGIN
    IF @Division = '003'
    BEGIN
        SELECT * 
        FROM dbo.view_LPA_Audits_with_Names
        WHERE division  = '001' OR division = '002' OR division = '003'
          AND auditdate BETWEEN @dateFrom AND @dateTo
          AND ISNULL(AuditType, '') LIKE @AuditType
        ORDER BY auditdate
    END
    ELSE
    BEGIN
        SELECT * 
        FROM dbo.view_LPA_Audits_with_Names
        WHERE division LIKE @Division
          AND auditdate BETWEEN @dateFrom AND @dateTo
          AND ISNULL(AuditType, '') LIKE @AuditType
        ORDER BY auditdate
    END
END

0 个答案:

没有答案