一直卡在这问题上了,找不到原因。
我在初始化中指定了报表文件地址,代码如下
this.components = new Container(); ReportDataSource reportDataSource = new ReportDataSource(); ReportDataSource reportDataSource2 = new ReportDataSource(); ReportDataSource reportDataSource3 = new ReportDataSource(); this.SSDataTableBindingSource = new BindingSource(this.components); this.XMLDataSet = new XMLDataSet(); this.BLSYReportViewer = new ReportViewer(); ((ISupportInitialize)this.SSDataTableBindingSource).BeginInit(); ((ISupportInitialize)this.XMLDataSet).BeginInit(); base.SuspendLayout(); this.SSDataTableBindingSource.DataMember = "SSDataTable"; this.SSDataTableBindingSource.DataSource = this.XMLDataSet; this.XMLDataSet.DataSetName = "XMLDataSet"; this.XMLDataSet.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema; this.BLSYReportViewer.Dock = DockStyle.Fill; reportDataSource.Value = null; reportDataSource2.Value = null; reportDataSource3.Name = "XMLDataSet_SSDataTable"; reportDataSource3.Value = this.SSDataTableBindingSource; this.BLSYReportViewer.LocalReport.DataSources.Add(reportDataSource); this.BLSYReportViewer.LocalReport.DataSources.Add(reportDataSource2); this.BLSYReportViewer.LocalReport.DataSources.Add(reportDataSource3); this.BLSYReportViewer.LocalReport.ReportEmbeddedResource = "NSMedicalRecords.FirstRecordPageDesign.rdlc";
求大神指导下,万分感激。
如果将ReportEmbeddedResource换成ReportPath,则程序报这个错
最好是VS2010以上版本做。VS2008会出错。
在Form里要放ReportViewer,然后这样调用:
1 // 定义好Report 2 3 ReportViewer1.LocalReport.ReportPath ="\\Report\\XX.rdlc"; 4 5 LocalReport localReportQuotation = ReportViewer1.LocalReport; 6 7 DataSet dsHeader = new DataSet("DataSet_Quotation"); 8 dsHeader = getHeader(quotationCode); 9 DataSet dsEntry = new DataSet("DataSet_Entry"); 10 dsEntry = getEntry(quotationCode); 11 12 ReportDataSource rdsHeader = new ReportDataSource(); 13 rdsHeader.Name = "DataSet_Header"; 14 rdsHeader.Value = dsHeader.Tables[0]; 15 16 ReportDataSource rdsEntry = new ReportDataSource(); 17 rdsEntry.Name = "DataSet_Entry"; 18 rdsEntry.Value = dsEntry.Tables[0]; 19 20 ReportViewer1.LocalReport.DataSources.Clear(); 21 localReportQuotation.DataSources.Add(rdsHeader); 22 localReportQuotation.DataSources.Add(rdsEntry); 23 ReportViewer1.LocalReport.Refresh();
我的是Webform的,Winform类似。
我用的就是VS2010阿,我做的也是Winform开发。我是在这段代码报错
1 this.BLSYReportViewer.LocalReport.SetParameters(new ReportParameter[] { reportParameter });
能帮我看一下是什么问题不?万分感谢阿!
string s = medicalRecordsContentEntity.MedicalContent.ToString(); XmlReader reader = XmlReader.Create(new StringReader(s)); XElement xElement = XElement.Load(reader); SystemSettingEntity systemSettingEntity = this._SystemSettingService.GetSystemSettingEntity("HospitalName"); ReportParameter reportParameter = new ReportParameter("txt_bt", systemSettingEntity.Value.ToString()); this.BLSYReportViewer.LocalReport.SetParameters(new ReportParameter[] { reportParameter }); ReportParameter reportParameter2 = new ReportParameter("zyh", xElement.Element("病案号").Value.ToString()); this.BLSYReportViewer.LocalReport.SetParameters(new ReportParameter[] { reportParameter2 });
@IT白痴: 我不太写Winform,但是可以这样试试:
首先,你的rdlc报表里是使用了DataSet吧。
1.先别用程序调用,先直接在report里看看,是否运行正确。
2. 看看你的Dataset是不是对?感觉您在这里会有点问题。
@酱油能: 嗯,我已经把问题搞定了。虽然不是你说的问题,但是也很感激你回复我,所以把分也给你。怎么我都发现没人来帮助新人 解决问题了呢?
@IT白痴: 谢谢,其实我也不是为了分。我自己也是个菜鸟,我知道菜鸟的痛苦。有空多交流。