前提・実現したいこと
Form12に日付入力とボタンを配置し、押下すると日付を条件にSQLによってDBよりレコードを取得します。その後Form16を開いて埋め込まれたreportviewer1にSQL結果を表示したいです。
発生している問題・エラーメッセージ
現在のコンテキストに 'reportViewer1' という名前は存在しません。
該当のソースコード
C#
1for (i = 0; i < count; ++i) 2{ 3 DataSet ds = new DataSet(); 4 command2.Parameters["@results"].Value = results[i]; 5 command2.CommandText = "select 材質1,径1,長さ1,数量1,単価1,硬度1,その他1,数量2,単価2,会社 from zairyoTBL where 入力日=@nyuryokudate2 and 会社=@results and フラグ is null"; 6 SqlDataAdapter Adp = new SqlDataAdapter(); 7 Adp.SelectCommand = command2; 8 Adp.Fill(ds);//データセットに格納 9 10 Form16 form16 = new Form16(); 11 12 // ReportViewer の初期設定 13//ここのreportViewer1が見に行けない。 14 reportViewer1.Reset(); 15 reportViewer1.ProcessingMode = ProcessingMode.Local; 16 reportViewer1.LocalReport.ReportPath = @"・・・・Report1.rdlc"; 17 18 // ReportViewer 用データセットの作成 19 ReportDataSource RepDS = new ReportDataSource(); 20 RepDS.Name = "DataSet1"; 21 RepDS.Value = ds.Tables[0]; 22 23 // ReportViewer にデータを表示 24 reportViewer1.LocalReport.DataSources.Add(RepDS); 25 reportViewer1.RefreshReport(); 26 27 form16.Show(); 28 form16.Dispose(); 29}
試したこと
このエラーはform16のreportViewer1をform1から見に行けてないのだと思い、form16.reportViewer1としたのですが、すると「'Form16.reportViewer1' はアクセスできない保護レベルになっています」と出てしまいます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/23 05:39