本文介绍了将多个参数传递给Crystal Report的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Visual Studio 2008和SQL Server 2008(语言为C#)
I'm working on Visual Studio 2008 and SQL Server 2008, language C#
我想将多个参数传递给ASP.NET中的Crystal Report.我有两个参数@accountnumber
和@customerid
.但是我只能将一个参数传递给我的报告,如下面的代码所示.
I want to pass multiple parameters to Crystal Report in ASP.NET. I have two parameters @accountnumber
and @customerid
. But I can only pass one parameter to my report as in code below.
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.ServerName = "CJ-PC";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.UserID = "sa";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.Password = "***";
CrystalReportViewer1.LogOnInfo[0].ConnectionInfo.DatabaseName = "Online";
string accountnumber = "acc001";
string customerID = "cus001";
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "@account_number";
paramDiscreteValue.Value = accountnumber;
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
ParameterField paramField1 = new ParameterField();
ParameterFields paramFields1 = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
paramField1.Name = "@account_number";
paramDiscreteValue1.Value = accountnumber;
paramField1.CurrentValues.Add(paramDiscreteValue1);
paramFields1.Add(paramField1);
paramField1.Name = "@customer_id";
paramDiscreteValue1.Value = customerID;
paramField1.CurrentValues.Add(paramDiscreteValue1);
paramFields1.Add(paramField1);
CrystalReportViewer1.ParameterFieldInfo = paramFields1;
推荐答案
在为paramField1
paramField1.Name = "@account_number";
paramDiscreteValue1.Value = accountnumber;
paramField1.CurrentValues.Add(paramDiscreteValue1);
paramFields1.Add(paramField1);
//Here is the missing code
paramField1 = new ParameterField();
paramField1.Name = "@customer_id";
paramDiscreteValue1.Value = customerID;
paramField1.CurrentValues.Add(paramDiscreteValue1);
paramFields1.Add(paramField1);
这篇关于将多个参数传递给Crystal Report的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!