簡體   English   中英

Crystal報表查看器給我錯誤:“提供了無效的參數。 無法打開行集。”

[英]Crystal report viewer giving me error : “Invalid Argument provided. Failed to open a rowset.”

我有一個水晶報表,將用存儲過程填充,但是當我將過程的任何參數放在.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();
protected void Page_Load(object sender, EventArgs e)
    {    
      if (Session["ReportDataSet"] != null)
         {
           crvAccountReportParameter.ReportSource = (ReportDocument)Session["ReportDataSet"];
         }
    }
private void LoadReport()
{
    doc = new ReportDocument();
    DataSet dsData = null;
    dsData = objAccountReportBAL.getAccountRegister(txtTotalBetweenFrom.Text.ToString(), txtTotalBetweenTo.Text.ToString());            
    doc.Load(Server.MapPath("CrSalesReport.rpt"));      
    doc.SetDataSource(dsData.Tables[0]); 
    Session["ReportDataSet"] = rptDoc;
    crvAccountReportParameter.ReportSource = rptDoc;
    crvAccountReportParameter.DataBind();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM