TableLogOnInfo logOnInfo = new TableLogOnInfo ();
//这里必须事先申明一个ReportDocument对象 Report,同时加载数据报表
ReportDocument oRpt = new ReportDocument();
//获取.rpt文件真实路径
string path1,path2;
path1= ("F:\\TGHL3");
path2=path1+"\\ssfa_rwb.rpt";
oRpt.Load (path2);
oRpt.Load ("F:\\TGHL3\\ssfa_rwb.rpt");
crystalReportViewer1.ReportSource = oRpt;

解决方案 »

  1.   

    //取得所需的数据,做一个数据集,将它赋给你做的报表的一个对象 ,两者的字段要对应,
    //再将这个报表对象赋给一个CrystalReportViewer,就可以
    DataSet dsdataSet =new DataSet();
    SqlConnection scn=new SqlConnection (DataConnString);
    scn.Open();
    SqlDataAdapter sdaXReport;Rpt_X oRpt_1 =new Rpt_X();    // Rpt_X 设计好的报表名
    sdaXReport=new SqlDataAdapter(pCommandText,scn);
    sdaXReport.Fill(dsdataSet,"table");
    //使用“报表引擎”对象模型将填充的数据集,传递给报表oRpt_1.SetDataSource(dsdataSet.Tables["table"]);rpt.ReportSource = oRpt_1; //rpt 为 CrystalReportViewer
      

  2.   

    谢谢大大们现在是报表已经设计好了,数据页准备好了就需要用代码来直接打印,不通过了那个CrystalReportViewer,就是点了某个按钮后直接就打印出来
      

  3.   

    private ReportDocument rep;
    rep.SetDataSource(ds)
    int intPrintCount=1;
    int intPrintStartPage=0;
    int intPrintEndPage=0;
    rep.PrintOptions.PrinterName="打印机名"
    rep.PrintToPrinter(intPrintCount,false,intPrintStartPage,intPrintEndPage);