我使用vs 2010 c#的水晶报表,并使用CR的rpt文档创建PDF文件。Crystal Reports加载报告文档失败
我把这段代码放在windows服务上,我的代码正常工作30 - 40次,但随后内存每上升+5 +7就会上升。
最后我得到这样的错误:加载文件失败!
我的代码:(我想我处理/关闭康恩却怎么)
private void ReportLogin(ReportDocument crDoc, string Database, string Server, string UserID, string Password)
{
try
{
crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = Server;
crConnectionInfo.DatabaseName = Database;
crConnectionInfo.UserID = UserID;
crConnectionInfo.Password = Password;
crDatabase = crDoc.Database;
crTables = crDatabase.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogonInfo = crTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogonInfo);
}
}
catch (Exception x)
{
throw x;
}
}
private void _CrystalReport(string RptFilePath)
{
reportDocument = LoadDoc(RptFilePath);
RptParamsWithType = new Dictionary<string, string>();
if (reportDocument.ParameterFields.Count > 0)
{
foreach (ParameterField pField in reportDocument.ParameterFields)
{
RptParamsWithType.Add(pField.Name, pField.ParameterValueType.ToString().Replace("Parameter", ""));
}
}
}
负载功能:
private ReportDocument LoadDoc(string RptFilePath)
{
try
{
reportDocument = new ReportDocument();
reportDocument.Load(RptFilePath);
return reportDocument;
}
catch (Exception x)
{
throw x;
}
}
我的功能,去年堪称是创建PDF:
public MemoryStream asPdf
{
get
{
using (TempMemoryStream = (MemoryStream)reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat))
{
return TempMemoryStream;
}
}
}
谢谢建议,帮我看看
这是你的代码的一部分,你设置的数据库登录,而不是在这里装载的报告(和你的错误是“装载文件失败!”)的一部分。你可能会展示你的工作的正确部分。 – 2013-05-08 10:06:08