我有一个水晶报告,将填充存储过程,但是当我将过程的任何参数放入 .rpt 文件时,它给了我类似的错误
“提供的参数无效。无法打开行集。”
我的代码如下:
public void GroupwiseRegistrationReport()
{
SqlConnection connection;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
connection = gen.con;
string SP = "";
SqlCommand command = connection.CreateCommand();
SqlTransaction transaction = null;
try
{
connection.Open();
transaction = connection.BeginTransaction();
if (rblReportFrom.SelectedValue == "0")
{
SP = "SPGroupwiseIndustriesEM1Report";
}
else
{
SP = "SPGroupwiseIndustriesEM2Report";
}
ValueData = new ArrayList();
ParameterData[0] = "@fromdate";
ValueData.Add(txtTotalBetweenFrom.Text.ToString().Trim());
ParameterData[1] = "@todate";
ValueData.Add(txtTotalBetweenTo.Text.ToString().Trim());
ds = gen.FunSearch_Trans(ParameterData, ValueData, SP, transaction, command);
dt = ds.Tables[0];
if (ds.Tables[0].Rows.Count > 0)
{
if (rblReportFrom.SelectedValue == "0")
{
repdoc.Load(Server.MapPath("~\\admin\\Reports\\Groupwise-EM-I-Registration-Report.rpt"));
}
else
{
repdoc.Load(Server.MapPath("~\\admin\\Reports\\Groupwise-EM-II-Registration-Report.rpt"));
}
repdoc.SetDataSource(ds.Tables[0]);
configureCrystalReports();
crvMSMEReportViewer.ReportSource = repdoc;
//Response.Buffer = true;
//Response.ClearContent();
//Response.ClearHeaders();
//repdoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Exported Report");
tablereportviewer.Visible = true;
}
else
{
tablereportviewer.Visible = false;
message("No Records Found.");
}
transaction.Commit();
}
catch (Exception ex)
{
tablereportviewer.Visible = false;
error.LogError(ex);
transaction.Rollback();
}
finally
{
connection.Close();
}
}
我错过了什么或我无法弄清楚请帮助我..
处理水晶报表的最佳方法是使用数据集还是直接存储过程?
更新
我改变了我的代码,如下所示,但现在给我的信息是:“缺少参数值。”。但我只有两个参数要传递,它们是“@fromdate”和“@todate”
这是一个代码片段:
doc = new ReportDocument();
doc.Load(Server.MapPath("~\\admin\\Reports\\Groupwise-EM-II-Registration-Report.rpt"));
doc.SetDatabaseLogon(ConfigurationManager.AppSettings["userName"], ConfigurationManager.AppSettings["pwd"], ConfigurationManager.AppSettings["serverName"], "databaseName", false);
doc.SetParameterValue("@fromdate", txtTotalBetweenFrom.Text.ToString());
doc.SetParameterValue("@todate", txtTotalBetweenTo.Text.ToString());
crvMSMEReportViewer.ReportSource = doc;
crvMSMEReportViewer.RefreshReport();