如何处理水晶报表应用之登录失败的问题?
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();
}
本文地址:http://www.45fan.com/a/question/72208.html