cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

May I preface that I am a first time user of these libraries and have just started this project with very little knowledge or help, just some examples of what our business has done in the past.

I'm building my project around reportxml.txt (attached, can't upload the actual report so I converted it with RptToXML).

The report has 1 main report and 2 subreports. the main has no parameters, which I'm using ReportDocument.RecordSelectionFormula instead for. there are 4 linked parameters on the subgroups.

I've been able to set the ConnectionInfo and DbConnectionAttributes correctly for the main report and subreports, and the ReportDocument.ReadRecords method appears to query the DB at least once correctly, according to SQL Server Profiler.

That is where everything shuts down. It doesn't make any further queries and when I try and export a document, there is nothing in it. ReadRecords produces 0 ReportDocument.Rows.

The report comes from a system that is currently querying the DB and successfully producing a report when I use their interface. I've watched the Sql Server profiler and it appears to query 3 times (one for main, 2 subreport queries) when running a report in their interface.

EDIT: using SAP Crystal Reports version: 13.0.3501

Here is the code I am using:

		static void SetConn(ReportDocument doc, ConnectionInfo cinfo)
			{
			Tables tables = doc.Database.Tables;


			foreach (Table table in tables)
				{
				TableLogOnInfo tableLogonInfo = table.LogOnInfo;
				tableLogonInfo.ConnectionInfo = cinfo;
				table.ApplyLogOnInfo(tableLogonInfo);
				}


			if (!doc.IsSubreport)
				{
				foreach (ReportDocument theSub in doc.Subreports)
					SetConn(theSub, cinfo);
				}
			}


		static void Main(string[] args)
			{
				string file = "C:\\report.rpt";
				try
					{
					ReportDocument doc = null;
					ConnectionInfo cinfo = new ConnectionInfo();
					DbConnectionAttributes dbAttributes = new DbConnectionAttributes();
					cinfo.LogonProperties.Clear();
					cinfo.Attributes.Collection.Clear();


					dbAttributes.Collection.Set("Auto Translate", "-1");
					dbAttributes.Collection.Set("Connect Timeout", "15");
					dbAttributes.Collection.Set("Data Source", "<servername>");
					dbAttributes.Collection.Set("General Timeout", "0");
					dbAttributes.Collection.Set("Initial Catalog", "<dbname>");
					dbAttributes.Collection.Set("Integrated Security", false);
					dbAttributes.Collection.Set("Locale Identifier", "1033");
					dbAttributes.Collection.Set("OLE DB Services", "-5");
					dbAttributes.Collection.Set("Provider", "SQLOLEDB");
					dbAttributes.Collection.Set("Tag with column collation when possible", "0");
					dbAttributes.Collection.Set("Use DSN Default Properties", false);
					dbAttributes.Collection.Set("Use Encryption for Data", "0");


					cinfo.LogonProperties.Clear();
					cinfo.Attributes.Collection.Clear();
					cinfo.DatabaseName = "<dbname>";
					cinfo.ServerName = "<servername>";
					cinfo.UserID = "<username>";
					cinfo.Password = "<password>";
					cinfo.Attributes.Collection.Set("Database DLL", "crdb_ado.dll");
					cinfo.Attributes.Collection.Set("QE_DatabaseName", "<dbname>");
					cinfo.Attributes.Collection.Set("QE_DatabaseType", "OLE DB (ADO)");
					cinfo.Attributes.Collection.Set("QE_LogonProperties", dbAttributes);
					cinfo.Attributes.Collection.Set("QE_ServerDescription", "<servername>");
					cinfo.Attributes.Collection.Set("QE_SQLDB", true);
					cinfo.Attributes.Collection.Set("SSO Enabled", false);
					cinfo.LogonProperties = dbAttributes.Collection;


					doc = new ReportDocument();
					doc.Load(file);


					SetConn(doc, cinfo);
					doc.Refresh();


					doc.RecordSelectionFormula = "{person.person_id}='86A835D1-F85C-4EEB-82CC-43866414F490' AND {patient_encounter.enc_id}='98AA1E61-9334-4D9E-A3D0-36E041FBCA31'";


					doc.VerifyDatabase();
					doc.ReadRecords();
					int rowcnt = doc.Rows.Count;
					
					doc.ExportToDisk(ExportFormatType.PortableDocFormat, @"C:\DocTemp\" + DateTime.Now.ToString("yyyyMMddHHmm") + ".pdf");




					}
				catch (Exception ex)
					{
					}

			}
0 Likes
View Entire Topic
0 Likes

Did you uninstall what ever previous version you had installed and replace all CR Assemblies with SP 29 and verify by looking a the properties of each assembly it's being loaded from the same location and same platform?

If all CR assemblies are x86 then you'll see this location for each dll.

C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.CrystalReports.Engine.dll

Check your references also, you should have all of these:

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.ReportDefModel;
using CrystalDecisions.ReportAppServer.CommonControls;
using CrystalDecisions.ReportAppServer.CommLayer;
using CrystalDecisions.ReportAppServer.CommonObjectModel;
using CrystalDecisions.ReportAppServer.ObjectFactory;
using CrystalDecisions.ReportAppServer.Prompting;
using CrystalDecisions.ReportAppServer.DataSetConversion;
using CrystalDecisions.ReportAppServer.DataDefModel;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Windows.Forms;
using CrystalDecisions.ReportAppServer.XmlSerialize;
Former Member
0 Likes

Since I'd like to be thorough and assure you're getting all the necessary tools to troubleshoot, here is a link to the report I'm trying to export as PDF:

report link

Former Member
0 Likes

Yes, I have verified All referenced files are from that directory (it is x86) and I've referenced all in the .CS file exactly as you state. I see no change in execution after verification to the resultant PDF, it's still blank after running. The previous code you shared still causes the same exception, and when the gp.FromString("*") line is commented out, returns 0 rows.

The database is still only being queried once when exporting, like so:

SELECT "person"."other_id_number", "person"."first_name", "person"."middle_name", "person"."last_name", "patient"."practice_id", "patient"."person_id", "person"."person_id", "patient_encounter"."enc_id" FROM ("patient" "patient" INNER JOIN "person" "person" ON "patient"."person_id"="person"."person_id") INNER JOIN "patient_encounter" "patient_encounter" ON ("patient"."practice_id"="patient_encounter"."practice_id") AND ("patient"."person_id"="patient_encounter"."person_id") WHERE "person"."person_id"='86A835D1-F85C-4EEB-82CC-43866414F490' AND "patient_encounter"."enc_id"='98AA1E61-9334-4D9E-A3D0-36E041FBCA31'

The interface that IS working correctly (not mine) queries the database 3 times, once EXACTLY the same as above and 2 others, like so:

SELECT "fdb_medication"."brand_name", "patient_medication"."sig_desc", "patient_medication"."date_stopped", "patient"."practice_id", "patient"."person_id", "patient_medication"."reprndc_ind", "fdb_medication"."dose" FROM ("patient" "patient" INNER JOIN "patient_medication" "patient_medication" ON ("patient"."person_id"="patient_medication"."person_id") AND ("patient"."practice_id"="patient_medication"."practice_id")) INNER JOIN "fdb_medication" "fdb_medication" ON "patient_medication"."ndc_id"="fdb_medication"."ndc_id"

SELECT "patient_allergy"."allergy_comment", "patient_allergy"."rxn_desc", "patient_allergy"."person_id", "allergy_mstr"."description", "patient_allergy"."allergy_type", "patient_allergy"."allergy_type_id", "allergy_type_mstr"."allergy_type_id", "allergy_mstr"."allergy_type_id", "patient_allergy"."practice_id" FROM ("NGDemo"."dbo"."patient_allergy" "patient_allergy" INNER JOIN "NGDemo"."dbo"."allergy_mstr" "allergy_mstr" ON "patient_allergy"."allergy_id"="allergy_mstr"."allergy_id") INNER JOIN "NGDemo"."dbo"."allergy_type_mstr" "allergy_type_mstr" ON ("patient_allergy"."allergy_type_id"="allergy_type_mstr"."allergy_type_id") AND ("allergy_mstr"."allergy_type_id"="allergy_type_mstr"."allergy_type_id") WHERE "patient_allergy"."practice_id"='0002' AND "allergy_mstr"."allergy_type_id"="allergy_type_mstr"."allergy_type_id" AND "patient_allergy"."allergy_type_id"="allergy_type_mstr"."allergy_type_id" AND "patient_allergy"."person_id"='86A835D1-F85C-4EEB-82CC-43866414F490' ORDER BY "patient_allergy"."person_id"

Could you re-evaluate my code in the original post? I have to be missing something here.