-1

RDLC を使用して Local Report を使用して Windows アプリケーションをビルドします。コードを VS2012 内で実行するとうまく機能しますが、展開すると、アプリケーションでいくつかのエラーが発生します。

ローカル レポートの処理中にエラーが発生しました。

レポート「Report1.rdlc」のレポート定義が指定されていません

パス「C:...\Report1.rdlc」の一部が見つかりませんでした。

使用しているコード:

DataSet2 ds = new DataSet2();
                DataTable dt = ds.Table2;

                DataRow dr = null;
                for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                {
                    dr = ds.Table2.NewRow();
                    dr["Nr"] = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    dr["Ary"] = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    dr["Car"] = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    dr["Total"] = dataGridView1.Rows[i].Cells[3].Value.ToString();
                    dr["Total2"] = dataGridView1.Rows[i].Cells[4].Value.ToString();
                    // MessageBox.Show(dr["Vetura"].ToString());
                    ds.Table2.Rows.Add(dr);
                    dt.AcceptChanges();
                }

                dr.AcceptChanges();

               

                string exeFolder = (Path.GetDirectoryName(Application.StartupPath)).Substring(0, (Path.GetDirectoryName(Application.StartupPath)).Length - 3);
                string reportPath = Path.Combine(exeFolder, @"Report1.rdlc");
                //MessageBox.Show(reportPath.ToString());
                Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet2", ds.Tables[0]);
                ra.reportViewer1.LocalReport.DataSources.Clear();
                ra.reportViewer1.LocalReport.DataSources.Add(rds);
                ra.reportViewer1.LocalReport.ReportPath = reportPath;
                if (textBox2.TextLength > 0)
                {
                    ReportParameter Percentage = new Microsoft.Reporting.WinForms.ReportParameter("Percentage", "-" + textBox2.Text + "%");
                    ReportParameter Total = new Microsoft.Reporting.WinForms.ReportParameter("Total", textBox3.Text);
                    ra.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Percentage });
                    ra.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Total });
                }
                //HERE IS THE FIRST ERROR , WHEN I PASS THE THE TEXT TO THE PARAMETER
                ReportParameter Klienti = new Microsoft.Reporting.WinForms.ReportParameter("Klienti", textBox1.Text);
                ra.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Klienti });
                ra.reportViewer1.RefreshReport();
4

1 に答える 1

0

Ganesh RI のおかげで問題を解決できました。ReportPath をコードで手動で指定していたので、 ReportViewer でパスを選択して自動的に指定したところ、うまくいきました。

于 2015-08-02T13:06:49.310 に答える