C# 如何使用asp.net c中的报表查看器使过滤器工作以生成报表#

C# 如何使用asp.net c中的报表查看器使过滤器工作以生成报表#,c#,asp.net,C#,Asp.net,我有这个密码,但它不起作用。。它不过滤任何东西。。当我生成一些东西时..我不知道为什么..有人能帮我修复这个。。??我需要创造一些东西。 以下是我正在使用的代码: public DataTable getDocumentsByFilter(string category, string document, string office, string period, DateTime start, DateTime end, string sy, string sem, string search

我有这个密码,但它不起作用。。它不过滤任何东西。。当我生成一些东西时..我不知道为什么..有人能帮我修复这个。。??我需要创造一些东西。 以下是我正在使用的代码:

public DataTable getDocumentsByFilter(string category, string document, string office, string period, DateTime start, DateTime end, string sy, string sem, string searchinfo)
{
    string sql = "SELECT d.*,so.*,sy.*,ua.*,so.SchoolOfficeDescription as [AddresseeName] From Document d, SchoolOffice so, SchoolYear sy, UserAccount ua WHERE d.Addressee = so.SchoolOfficeID AND d.SchoolYearID = sy.SchoolYearID AND d.Status like 'Active' AND ua.UserID = d.UserID";

    if (!(office == "All")) 
    {
        sql = sql + " And  d.Addressee =" + office ;
    }
    else if (office == "All")
    {
        sql = sql + " AND  d.Addressee >= 0 ";
    }

    if (!(document == "All"))
    {
        sql = sql + document + "";
    }
    else
    {
        sql = sql + " AND ( d.docStatus like 'Draft' OR d.docStatus like 'Forwarded' OR d.docStatus like 'Received') ";
    }

    if (!(category == "All"))
        sql = sql + " And d.Category like '" + category+ "'";
    else
    {
        sql = sql + " AND ( d.Category like 'Activity,Item,Service' OR  d.Category like 'Activity' OR  d.Category like 'Item' or  d.Category like 'Service')";
    }

    if (period == "SY")
    {
        sql = sql + " And sy.YearStart like '" + sy + "'";

        if (!(sem == "Please select..."))
        {
            sql = sql + " And sy.Semester like '" + sem + "'";
        }
        else 
        {
            sql = sql + " And (sy.Semester like 'First Semester' OR sy.Semester like 'Summer Term' or sy.Semester like 'Second Semester') ";
        }
    }
    else if (period == "Date")
    {
        sql = sql + " And d.DateCreated between '" + start + "' And '" + end + "'";
    }
    else if (period == "All")
    {
        sql = sql + " AND d.DateCreated  > '1/1/1911 12:00:00 AM' ";
    }

    if (searchinfo != "Enter document details")
    {
        sql = sql + " AND ((ua.FirstName like '%" + searchinfo + "%' OR ua.LastName like '%" + searchinfo + "%') AND ua.UserID = d.UserID)";
    }

    sql = sql + " ORDER BY d.DateCreated DESC";

    return GetDataTable(sql, null);
}

你有什么结果吗?结果出了什么问题?我们需要更多关于期望行为和实际行为之间差异的详细信息,以提供更多帮助。我没有得到任何结果。当我选择过滤某些内容时,gridview是空白的。您调试了代码吗?有例外吗?您是否尝试过手动运行您的代码在查询工具中生成的SQL?是的,我已经更改了查询。但它不起作用