日期:2014-05-19  浏览次数:20853 次

datagird中显示报表中不显
private   void   BindIOProductData(int   nStoreInOutID)
{
///定义获取数据的类
MisStock.Components.IOProduct   product   =   new   MisStock.Components.IOProduct();
SqlDataReader   recp   =   product.GetProductByStoreInOut(nStoreInOutID);

///创建DataSet数据源
DataTable   dataTable   =   SystemTools.ConvertDataReaderToDataTable(recp);
DataSet   dataSet   =   new   DataSet( "IOProduct ");
dataSet.Tables.Add(dataTable);

///设定控件的数据源
IOProductList.DataSource   =   dataSet;
///绑定控件的数据
IOProductList.DataBind();
}

绑定到DataGrid上显示没问题。

===============================

private   void   BindProductData(int   nStoreInOutID)
{
    MisStock.Components.IOProduct   product   =   new   MisStock.Components.IOProduct();
SqlDataReader   recp   =   product.GetProductByStoreInOut(nStoreInOutID);

//创建DataSet数据源
DataTable   dataTable   =   SystemTools.ConvertDataReaderToDataTable(recp);
                        CrystalReport2   oCR=   new   CrystalReport2();
              DataSet1   ds   =   new   DataSet1();
ds.Tables.Add(dataTable);
oCR.SetDataSource(ds);
oCR.SetDatabaseLogon( "sa ", " ", "HWB ", "ASPNETMisDB ");
                       
this.CrystalReportViewer1.ReportSource=oCR;
this.CrystalReportViewer1.Zoom(1);
}  
=====================================

就不显示是空的用的是模式数据集,那位高手指点一二,谢谢!


------解决方案--------------------
sf
------解决方案--------------------
不懂,学习来了,帮顶吧
你能给我一分就不错了,谢谢!
------解决方案--------------------
顶上去,高手就在楼下
------解决方案--------------------
up
------解决方案--------------------
up
------解决方案--------------------
单从语法上看不出来什么错误,
用oCR.SetDataSource(ds.Tables[0]);试试--指定到table
------解决方案--------------------
你的CrystalReport2是不是有問題?你看看CS源碼。
public class CrystalReport2 : ReportClass {

public CrystalReport2() {
}

public override string ResourceName {
get {
return "CrystalReport2.rpt ";//是否讀入正確的報表
}
set {
// Do nothing
}
}
------解决方案--------------------
学习