您的位置:首页 > 其它

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

2004-12-10 10:44 519 查看
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";
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= @"d:/CrystalReport1.pdf";
dd.DiskFileName =pdfname; //Save as a PDF file

rd.ExportOptions.DestinationOptions = dd;
rd.ExportOptions.ExportDestinationType=ExportDestinationType.DiskFile;
rd.ExportOptions.ExportFormatType=ExportFormatType.PortableDocFormat;
rd.Export();
rd.Close();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType="application/pdf";
Response.WriteFile(pdfname);
Response.Flush();
Response.Close();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: