调用rdlc好表提示:尚未指定报表定义的来源
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
namespace 产成品库存管理
{
public partial class FrmPrintReport : Form
{
private string DisplayName;
private string RDLCName;
private printReportName ReportName;
private string[] sqlString;
DataAccess Sql;
public FrmPrintReport(printReportName reportName)
{
InitializeComponent();
this.ReportName = reportName;
sqlString = new string[] {
"???",
"select b.编号 as 产品编号,b.品名 as 产品名称,当前库存数量 from 产成品库存数量表 as a inner join 生产工艺 as b on a.产品编号=b.编号 where 当前库存数量<>0"
};
Sql = new DataAccess();
}
private void FrmPrintReport_Load(object sender, EventArgs e)
{
switch (ReportName)
{
case printReportName.deliverGoods:
loadReport("ReportDeliverGoods.rdlc","产成品送货单",sqlString[0]);
break;
case printReportName.stockCheck:
loadReport("ReportStockCheck.rdlc", "产成品库存盘点表", sqlString[1]);
break;
}
}
private DataSet Ds;
private void loadReport(string rdlcName,string displayName,string sqlString)
{
report.Reset();
report.LocalReport.DataSources.Clear();
report.LocalReport.DisplayName = displayName;
Ds = Sql.getDataSet(sqlString);
List<ReportStockCheck> list = new List<ReportStockCheck>();
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
{
ReportStockCheck rsc = new ReportStockCheck();
rsc.ProductID = Ds.Tables[0].Rows[0][0].ToString();
rsc.ProductName = Ds.Tables[0].Rows[0][1].ToString();
rsc.StockAmount = Ds.Tables[0].Rows[0][2].ToString();
list.Add(rsc);
}
BindingSource bSource = new BindingSource(list, "");
report.LocalReport.ReportPath = Application.StartupPath + "\\" +rdlcName;
//report.LocalReport.ReportEmbeddedResource = "产成品库存管理.ReportStockCheck.rdlc";
ReportDataSource rSource = new ReportDataSource("产成品库存管理_ReportStockCheck", bSource);
report.LocalReport.DataSources.Add(rSource);
//report.LocalReport.DataSources.Add(new ReportDataSource("产成品库存管理_ReportStockCheck", list));
report.RefreshReport();
}
}
}
public class ReportStockCheck
{
private string costomerName;
public string CostomerName
{
get
{
return costomerName;
}
set
{
costomerName = value;
}
}
private string productID;
public string ProductID
{
get
{
return productID;
}
set
{
productID = value;
}
}
private string productName;
public string ProductName
{
get
{
return productName;
}
set
{
productName = value;
}
}
private string stockAmount;
public string StockAmount
{
get
{
return stockAmount;
}
set
{
stockAmount = value;
}
}
} --------------------编程问答-------------------- 已经解决,少了一句:report.ProcessingMode = ProcessingMode.Local; --------------------编程问答-------------------- 我也在用这个,但是没报错,就是数据显示不出来 --------------------编程问答-------------------- --------------------编程问答-------------------- 指定一下源
reportViewer.LocalReport.ReportPath = "Report1.rdlc"; --------------------编程问答-------------------- 1楼别误人子弟 --------------------编程问答-------------------- 楼主代码放在【code=C#】【/code】里啊 --------------------编程问答-------------------- 看一下这个路径:report.LocalReport.ReportPath = Application.StartupPath + "\\" +rdlcName; 是不是不对啊,一般报表自动生成的不会在这个路径下啊:Application.StartupPath
--------------------编程问答-------------------- 大家都回复了,路径
补充:.NET技术 , C#