网上找的例子是这样的
private void button2_Click(object sender, EventArgs e) { FastReport.TfrxReportClass report = new FastReport.TfrxReportClass(); report.MainWindowHandle = (int)this.Handle; report.LoadReportFromFile("report\\jhjl.fr3");//添加报表路径 FrxDataTable rptdataset1 = new FrxDataTable("adoquery1"); FrxDataTable rptdataset2 = new FrxDataTable("adoquery2"); OleDbDataAdapter oleDbDataAdapter1 = new OleDbDataAdapter("select * from TZ_Unit", Class1.conn1); oleDbDataAdapter1.Fill(rptdataset1); OleDbDataAdapter oleDbDataAdapter2 = new OleDbDataAdapter(listsql, Class1.conn1); oleDbDataAdapter2.Fill(rptdataset2); // rptdataset1.AssignToReport(true, report); // rptdataset2.AssignToReport(true, report); // rptdataset2.AssignToDataBand("MasterData1", report); report.ShowReport(); }
我照着这个用第二次打开报表报错,后来发现.ClearDatasets();方法,要在实例后添加,第二次不报错。
report = new TfrxReportClass(); report.ClearDatasets(); report.SetGlobalVariable("Language", "Chinese");