473,382 Members | 1,225 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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 3531
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: kristoff plasun | last post by:
I have a problem with a C++ DCOM application that prints Crystal Reports with data from Oracle. The SQL query is relatively complex but when the report is printed from the Crystal Reports...
3
by: Gheaci Maschl | last post by:
Hi all! I would like to have your opinion about my problem and my proposal how to solve it: Ingredients: - BTriev database - Crystal Reports - maybe MS Access - Liinos6 (small ERP software)
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
7
by: John | last post by:
I am using Crystal Reports in my application I made using Visual Studio.NET. I installed my application on the client machine, with all the DLLs required(added the merge modules), the engine and...
2
by: fig000 | last post by:
Hi everyone, I recently wrote a vb.net app which includes some crystal reports. The user has very little money in their budget and have been without a working application for quite a while. This...
17
by: Peter Proost | last post by:
Hi Group, I've got an interesting problem, I don't know if this is the right group but I think so because everything I've read about it so far says it's a .net problem. Here's the problem, we're...
1
by: Lyners | last post by:
Hello all, I have created an ASP.NET website that uses Crystal Reports that works on the localhost (my PC), but when I copy it to the server it does not. The problem is...
2
by: matt | last post by:
hello, i have an .RPT file that i am using to load a report via the ASP.NET CrystalReportViewer control. i dont include my .RPTs as embedded resources...instead i load the absolute path of the...
1
by: appandairajc | last post by:
Hi Friends, I have a problem in Crystal Reports. I have a web application and it was published in machine. I am running that application through a virtual path. All the pages are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.