0
我有一個水晶報表,那就是充滿存儲過程,但是當我在.rpt文件放在程序的任何參數,它給我的錯誤一樣Crystal報表查看器給我錯誤:「提供的無效參數。無法打開行集。」
「提供的參數無效。無法打開一排排「。
我的代碼如下:
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();
它不工作,但你能否詳細說明你是怎麼做什麼? –
將參數設置爲我的代碼中的這種類型。 –
試試此代碼作爲參考代碼 –