≡≡JABBY's Blog≡≡

菩提本无树,明镜亦非台,本来无一物,何处惹尘埃

水晶报表应用之登录失败及导出解决方案

ReportDocument rd = new ReportDocument();
  
  private void setcry()
  {
   TableLogOnInfo t=new TableLogOnInfo();

   rd.Load(Server.MapPath("CrystalReport1.rpt")); //Load the Crystal Report

   t.ConnectionInfo.ServerName="localhost";   //log the connection info here
   t.ConnectionInfo.DatabaseName="Northwind";
   t.ConnectionInfo.UserID="xxx";
   t.ConnectionInfo.Password="xxx";


   rd.Database.Tables["Categories"].ApplyLogOnInfo(t);//Save the connection info

   DiskFileDestinationOptions dd = new  DiskFileDestinationOptions();
   string pdfname= @"..\CrystalReport1.pdf";
   dd.DiskFileName =pdfname;  //Save as a PDF file

   rd.ExportOptions.DestinationOptions = dd;
   rd.ExportOptions.ExportDestinationType=ExportDestinationType.DiskFile;
   rd.ExportOptions.ExportFormatType=ExportFormatType.PortableDocFormat;  // set the PDF format
   rd.Export();
   rd.Close();


   Response.ClearContent();  //And the write the PDF file to the page
   Response.ClearHeaders();
   Response.ContentType="application/pdf";
   Response.WriteFile(pdfname);
   Response.Flush();
   Response.Close();
  }

posted on 2004-12-23 19:25    阅读(1231)  评论(0编辑  收藏  举报

导航