471,603 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 software developers and data experts.

Crystal Reports 8.5 with C# problem

Hi all, I have a piece of code in my C# console application to export from
crystal report files to PDF. For some reports files, I get errors below. I
have Crystal Reports 8.5 with service pack installed on my local machine.
What is the reason to cause this "Unknown Query Engine Error"? This is a
report with 3 sub-reports, is there anything missing in my code to handle
this type of reports?

Thanks a lot!

=====================Error Call Stack Begins============================
Error Message: Unknown Query Engine Error
Error Source: CrystalDecisions.CrystalReports.Engine
Error Stack Trace: at .F(String  , EngineExceptionErrorID  )
at .A(Int16 , Int32 )
at .@(Int16 )
at
CrystalDecisions.CrystalReports.Engine.FormatEngin e.Export(ExportRequestContext
reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngin e.Export()
at CrystalDecisions.CrystalReports.Engine.ReportDocum ent.Export()
at MyApp.MyClass.CrystalReportsNet.exportReport(Strin g reportPath, String
reportNameCode, DateTime startDate, DateTime endDate, Int32 saveOrPrint,
ReportDocument rd) in c:\work\crystalreportsnet.cs:line 258
Error TargetSite: Void F(System.String,
CrystalDecisions.CrystalReports.Engine.EngineExcep tionErrorID)
ErrorID: DataSourceError
HelpLink: NULL

=======================Souce Code Begins Here========================
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
.......
ReportDocument rd = new ReportDocument();
rd.Load(@"c:\temp\a.rpt");

ParameterFieldDefinitions crParams = rd.DataDefinition.ParameterFields;
foreach (ParameterFieldDefinition def in crParams) {
if (def.IsLinked()) {
continue;
}
string paramName = def.ParameterFieldName;

// create new Parameter Discrete Value object
ParameterDiscreteValue paramValue = new ParameterDiscreteValue();

// Set value of Discrete value object
switch (paramName.ToUpper()) {
case "@DEALERID":
paramValue.Value = dealerID;
break;
case "@LANGUAGEID":
paramValue.Value = languageID;
break;
case "@REPORTTYPE":
paramValue.Value = MPAReportType;
break;
case "@RPTMONTH":
paramValue.Value = month;
break;
case "@RPTYEAR":
paramValue.Value = year;
break;
case "@CURRENTMONTH":
paramValue.Value = month;
break;
case "@CURRENTYEAR":
paramValue.Value = year;
break;
}

// extract collection of current values
ParameterValues currentValues = def.CurrentValues;

// Add Discrete value object to collection of current values
currentValues.Add(paramValue);

// apply modified current values to param collection
def.ApplyCurrentValues(currentValues);
}

foreach (Section sec in rd.ReportDefinition.Sections) {
foreach (ReportObject report in sec.ReportObjects) {
if (report.Kind == ReportObjectKind.SubreportObject) {
SubreportObject subreport = (SubreportObject)report;
ReportDocument subRepDoc =
subreport.OpenSubreport(subreport.SubreportName);

foreach (Table tbl in subRepDoc.Database.Tables) {
TableLogOnInfo tliCurrent = tbl.LogOnInfo;
tliCurrent.ConnectionInfo.ServerName = "MyODBC";
tliCurrent.ConnectionInfo.DatabaseName = "MyDatabase";
tliCurrent.ConnectionInfo.UserID = "MyUsername";
tliCurrent.ConnectionInfo.Password = "MyPassword";
tbl.ApplyLogOnInfo(tliCurrent);
}
}
}
}

foreach (Table tbl in rd.Database.Tables) {
TableLogOnInfo tliCurrent = tbl.LogOnInfo;
tliCurrent.ConnectionInfo.ServerName = "MyODBC";
tliCurrent.ConnectionInfo.DatabaseName = "MyDatabase";
tliCurrent.ConnectionInfo.UserID = "MyUsername";
tliCurrent.ConnectionInfo.Password = "MyPassword";
tbl.ApplyLogOnInfo(tliCurrent);
}

try {
DiskFileDestinationOptions save = new DiskFileDestinationOptions();
save.DiskFileName = @"c:\temp\a.pdf";
ExportOptions exp = new ExportOptions();
exp = rd.ExportOptions;
exp.ExportDestinationType = ExportDestinationType.DiskFile;
exp.ExportFormatType = ExportFormatType.PortableDocFormat;
exp.DestinationOptions = save;
rd.Export();

return true;
} catch {
//.......
}

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Dec 7 '05 #1
1 3428
Hi Hardy,

The Crystal Report is a third-party software integrated with the VS.NET
IDE, and it is not supported by Microsoft, please refer to the following KB
article for the information on the licensing and support on Crystal Report:
INFO: Licensing and Support for Crystal Reports for Visual Studio .NET
http://support.microsoft.com/?id=317789

If you have more concern on this issue, I suggest you contact crystal
report support for help:
http://support.businessobjects.com/

And the following is the Forum where you will receive some specific helps:
http://support.businessobjects.com/f...id=2-5-1&sk=5&

Thanks for your understanding!
Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Dec 8 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by kristoff plasun | last post: by
3 posts views Thread by Gheaci Maschl | last post: by
7 posts views Thread by p | last post: by
17 posts views Thread by Peter Proost | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by MichaelMortimer | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.