我有一个用VB2005构建的报告。它在报表生成器中完美运行,并且可以在服务器上的报表管理器中运行。
我有一个aspx页面,但是有一个报表查看器,它返回0结果。
报告呈现,但不返回任何数据。
这是我的SQL代码:
SELECT v_rpt_Company.Company_Name, SO_Activity.Subject, SO_Activity.Notes, SO_Activity.Date_Closed, SO_Activity.Last_Update, v_rpt_Member.Member_ID,
v_rpt_ActivityType.SO_Activity_Type_Desc, v_rpt_ActivityStatus.SO_Act_Status_Desc
FROM v_rpt_Company LEFT OUTER JOIN
SO_Activity ON v_rpt_Company.Company_RecID = SO_Activity.Company_RecID LEFT OUTER JOIN
v_rpt_Member ON SO_Activity.Assign_To = v_rpt_Member.Member_ID LEFT OUTER JOIN
Company_Team ON v_rpt_Member.Member_RecID = Company_Team.Member_RecID AND
v_rpt_Company.Company_RecID = Company_Team.Company_RecID LEFT OUTER JOIN
v_rpt_ActivityType ON SO_Activity.SO_Activity_Type_RecID = v_rpt_ActivityType.SO_Activity_Type_RecID LEFT OUTER JOIN
v_rpt_ActivityStatus ON SO_Activity.so_act_status_recid = v_rpt_ActivityStatus.SO_Act_Status_RecID
WHERE (@acctmgr <> 'true' OR Company_Team.AcctMgr_Flag = 1) AND
(SO_Activity.Assign_To = @member) AND (v_rpt_ActivityStatus.SO_Act_Status_Desc = CASE WHEN @act_status IS NULL
THEN v_rpt_ActivityStatus.so_act_status_desc ELSE @act_status END) AND ((@company = '') OR (v_rpt_Company.Company_RecID = @company)) AND (SO_Activity.Last_Update >= CONVERT(datetime, @date_start, 101)) AND (SO_Activity.Last_Update <= CONVERT(datetime, @date_end, 101))
GROUP BY v_rpt_Company.Company_Name, SO_Activity.Subject, SO_Activity.Notes, SO_Activity.Date_Closed, SO_Activity.Last_Update, v_rpt_Member.Member_ID,
v_rpt_ActivityType.SO_Activity_Type_Desc, v_rpt_ActivityStatus.SO_Act_Status_Desc
ORDER BY v_rpt_Company.Company_Name, SO_Activity.Last_Update DESC
这是我的asp.net代码:
<div style="text-align:center;border-style:solid;border-width:3px; width:auto;height:auto;">
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
Height="700px" ProcessingMode="Remote" Width="100%" ShowParameterPrompts="False">
<ServerReport ReportPath="/path/report" ReportServerUrl="http:myserver/reportserver" />
</rsweb:ReportViewer>
</div>
这是我的C#:
/*
* Retrieve parameters from URL and send them to the report
*/
private void getParametersFromURL()
{
//Load Parameters from URL
//Requests that are commented, are commented because of lack of ConnectWise Support
String[] parameters = new String[7];
parameters[0] = Request.QueryString["acctmgr"];
parameters[1] = Request.QueryString["member"];
parameters[2] = Request.QueryString["details"];
parameters[3] = Request.QueryString["act_status"];
parameters[4] = Request.QueryString["company"];
parameters[5] = Request.QueryString["date_start"];
parameters[6] = Request.QueryString["date_end"];
//Create Parameter Collection Array
Microsoft.Reporting.WebForms.ReportParameter[] reportParameterCollection = new Microsoft.Reporting.WebForms.ReportParameter[parameters.Length];
//Loop through each parameter and load the name and value into the parameter collection
int i = 0;
foreach (String parameter in parameters)
{
reportParameterCollection[i] = new Microsoft.Reporting.WebForms.ReportParameter();
reportParameterCollection[i].Name = getParameterName(i);
reportParameterCollection[i].Values.Add(Convert.ToString(parameters[i]));
i++;
}
//Load Parameters into the ReportViewer
ReportViewer1.ServerReport.SetParameters(reportParameterCollection);
ReportViewer1.ServerReport.Refresh();
}
/*
* Takes the index of the element in the parameter array
* then returns the correct parameter name to return to the report viewer
*/
public String getParameterName(int number)
{
switch (number)
{
case 0:
return "AcctMgr";
case 1:
return "member";
case 2:
return "details";
case 3:
return "act_status";
case 4:
return "company";
case 5:
return "date_start";
case 6:
return "date_end";
default:
Response.Write("<script language='javascript'>alert('Error: getParameterName(number) failed. Parameter #: " + number + ");</script>");
return "error";
}
}
答案 0 :(得分:1)
我修好了。问题是act_status
根据reportviewer,显然是&act_status=&...
的网址字符串并不代表act_status = NULL
。
所以我改变了我的SQL以反映空字符串而不是NULL。