トップ回答者
『ローカルレポートの処理中にエラーが発生しました』のエラーが出る

質問
-
VS2008、C#のWEbサイトで
Report.rdlcにデータソースを追加すると、続行中にRenderのソースでエラーが発生します。
データソースを削除すると、エラーは発生しないで、テキストボックスのテストという文字がPDF形式できちんと出力されます。
サーバーにあるテーブルをReportで表示させたいのですが、エラーが起こり、前に進むことができません。
ご教授のほど宜しくお願いいたします。
DataSet ds = new DataSet();
DataSetTableAdapters.DataTable1TableAdapter DataTable1TableAdapter = new DataSetTableAdapters.DataTable1TableAdapter();
DataTable1TableAdapter.ClearBeforeFill = false;
DataTable1TableAdapter.Fill(ds.DataTable1);LocalReport report = new LocalReport();
report.ReportPath = HttpContext.Current.Request.PhysicalApplicationPath + "Report.rdlc";
ReportDataSource rds = new ReportDataSource();rds.Name = "DataSet";
rds.Value = ds.DataTable1;report.DataSources.Add(rds);
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;byte[] bLength = report.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); ←ここでエラーがでる。
if (bLength != null)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "Application/pdf";// ダイアログ表示
Response.AddHeader("content-disposition", "attachment; filename=" + ".pdf");// HTTP 出力ストリームに書き込み
Response.BinaryWrite(bLength);
Response.End();
}
回答
-
ReportDataSource.NameにではなくReportDataSource.DataMemberにレポートデータセット名を指定しましょう。
個別に明示されていない限りgekkaがフォーラムに投稿したコードにはフォーラム使用条件に基づき「MICROSOFT LIMITED PUBLIC LICENSE」が適用されます。(かなり自由に使ってOK!)
- 回答としてマーク 立花楓Microsoft employee, Moderator 2018年8月24日 7:38
すべての返信
-
ReportDataSource.NameにではなくReportDataSource.DataMemberにレポートデータセット名を指定しましょう。
個別に明示されていない限りgekkaがフォーラムに投稿したコードにはフォーラム使用条件に基づき「MICROSOFT LIMITED PUBLIC LICENSE」が適用されます。(かなり自由に使ってOK!)
- 回答としてマーク 立花楓Microsoft employee, Moderator 2018年8月24日 7:38