您的位置:首页 > 其它

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

2004-12-23 19:25 316 查看
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();

  }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: