1. Miguel Leeuwe
  2. PowerBuilder
  3. Sunday, 1 November 2020 18:04 PM UTC

Hi Guys and Girls,

I've made a (pretty chaotic, but maybe useful) presentation on how to get Crystal Reports working with powerbuilder:

1. Download the zip file and uncompress it: https://drive.google.com/file/d/12dCqtlXQZIJyyJ_sIWpfM4jHduvpu82z/view?usp=sharing

2. Then go through each of my videos. (excuses for not being as to the point and less chaotic, as it's my weekend and I'm veeeery tired).

step 1: https://drive.google.com/file/d/1dsZn6qr9wH0ID9n_jWOq8Y--f1m7hwwa/view?usp=sharing

step 2: https://drive.google.com/file/d/1en7Ng_VfPQqekmJSfztl5jeoNiPYIiy3/view?usp=sharing

step 3: https://drive.google.com/file/d/1vqDdCugBfexfD301tHQmU7Gw0cifGwuO/view?usp=sharing

step 4: https://drive.google.com/file/d/1D5K8663ltujL5mG4rCpc-m9_qZZysAe4/view?usp=sharing

 

hope it's any good to anyone

regards

Riccardo Pasqualetti Accepted Answer Pending Moderation
  1. Wednesday, 20 July 2022 13:09 PM UTC
  2. PowerBuilder
  3. # 1

Hi Miguel,

i have a small application in PB 2019 R3 that use your PBCrystalReportsViewer.

I have deployed my application to 64bit, installed on windows 64bit and installed runtime Crystal 64bit

When I run my application i have this error:

 

Maybe I should compile PBCrystalReportsViewer in 64bit?

Thanks in advance.

 

Umberto

 

Comment
  1. Miguel Leeuwe
  2. Wednesday, 20 July 2022 14:46 PM UTC
Pfuu! .. if I remember well, you need the same registry keys, but they have to be in the registry in the places corresponding to 64 bit. So not in the Wow6432Node, but one level up. There should be some instructions I think.

Also please change that Error message, as it mentions a company called "Credica" that I no longer work for :)

I'll change it when I have some time.
  1. Helpful
  1. Riccardo Pasqualetti
  2. Wednesday, 20 July 2022 15:34 PM UTC
It works!



Thanks.



Umberto

  1. Helpful
  1. Miguel Leeuwe
  2. Friday, 22 July 2022 03:35 AM UTC
That's good to hear!

You're welcome.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Monday, 27 September 2021 11:21 AM UTC
  2. PowerBuilder
  3. # 2

About parameters for CR:

This is what we do in Powerbuilder. First we did this in the Open event of our window, but if there's a popup in the crystal report asking for parameters, this would enter in and endless loop of asking for the parameters. Therefore we now do this in an event POSTED from the Open() event:

setpointer(hourglass!)	
try
	ole_crviewer.object.OpenReport(is_archive, 1, ls_server, ls_user, ls_pwd, is_window, ls_query, ls_install, ls_user_pass, ls_cust_pass, ls_database)
Catch (OLERuntimeError cr_rptsrc)
//	gnv_app.inv_error.of_message("Crystal Report", cr_rptsrc.getMessage() )
	setpointer(arrow!)
//	this.event pfc_close( )
	RETURN
End try	

Then in C# in the Crystal report viewer DLL we have this code for OpenReport():

public void OpenReport(string as_template, int ai_exclusive, string as_servername, string as_user,
						string as_pwd, string as_window,
						string as_query, string as_install, string as_user_pass, string as_cust_pass, 
                        string as_database) 
{

	int li_cont=0;
	List<string> list_parmNames = new List<string>();

	cryRpt.Load(as_template);

	TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
	TableLogOnInfo crTableLogonInfo = new TableLogOnInfo();
	ConnectionInfo crConnectionInfo = new ConnectionInfo();
	Tables CrTables;
	Tables CrSubRepTables;

	ParameterFieldDefinitions crParameterFieldDefinitions;
	ParameterValues crParameterValues = new ParameterValues();

	//-- store all parameters in an array (used later on):
	crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
	foreach (CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition crParmFld in crParameterFieldDefinitions)
	{
		list_parmNames.Add(crParmFld.ParameterFieldName);
		li_cont++;
	}
	string[] ls_parmNames = list_parmNames.ToArray();

	//-- logon all connections:
	crConnectionInfo.ServerName = as_servername;
	crConnectionInfo.DatabaseName = as_database; // u1, mjl, 10/04/17.
	crConnectionInfo.UserID = as_user;
	crConnectionInfo.Password = as_pwd;

	CrTables = cryRpt.Database.Tables;
	foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
	{
		crTableLogonInfo = CrTable.LogOnInfo;
		crTableLogonInfo.ConnectionInfo = crConnectionInfo;
		CrTable.ApplyLogOnInfo(crTableLogonInfo);
	}

	//-- logon all connections of the sub-reports:
	Sections crSections;
	ReportObjects crReportObjects;
	SubreportObject crSubreportObject;
	ReportDocument crSubreportDocument;

	//set the crSections object to the current report's sections
	crSections = cryRpt.ReportDefinition.Sections;

	//loop through all the sections to find all the report objects
	foreach (Section crSection in crSections)
	{
		crReportObjects = crSection.ReportObjects;
		//loop through all the report objects to find all the subreports
		foreach (ReportObject crReportObject in crReportObjects)
		{
			if (crReportObject.Kind == ReportObjectKind.SubreportObject)
			{
				//you will need to typecast the reportobject to a subreport 
				//object once you find it
				crSubreportObject = (SubreportObject)crReportObject;

				//open the subreport object
				crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);

				//set the database and tables objects to work with the subreport
				CrSubRepTables = crSubreportDocument.Database.Tables;

				//loop through all the tables in the subreport and 
				//set up the connection info and apply it to the tables
				foreach (Table CrTable in CrSubRepTables)
				{
					crTableLogonInfo = CrTable.LogOnInfo;
					crTableLogonInfo.ConnectionInfo = crConnectionInfo;
					CrTable.ApplyLogOnInfo(crTableLogonInfo);
				}
			}
		}
	}
	//////////////////////////////////////////
	// set paramaters
	//Log 2802,2803,2804 - Make sure parameters being passed exist - Patrick 24/01/06
	switch (as_window)
	{
		case "qprint":
			for (int i = 0; i < li_cont; i++)
			{
				if (ls_parmNames[i].ToLower() == "query")
				{
					cryRpt.SetParameterValue("query", as_query);
					break;
				}
			}
			break;

		case "cprint":
			for (int i = 0; i < li_cont; i++)
			{
				if (ls_parmNames[i].ToLower() == "contactno")
				{
					cryRpt.SetParameterValue("contactno", as_install); //&& we're not sure yet about this one
					break;
				}
			}
			break;

		case "iprint":
			for (int i = 0; i < li_cont; i++)
			{
				if (ls_parmNames[i].ToLower() == "install")
				{
					cryRpt.SetParameterValue("install", as_install);
					break;
				}
			}
			break;

		default:
			int li_ret, li_ret1;

			if (!(as_user_pass == null) || !(as_cust_pass == null))
			{
				li_ret = 0; li_ret1 = 0;
				if (!(as_cust_pass == null))
				{
					for (int i = 0; i < li_cont; i++)
					{
						if (ls_parmNames[i].ToLower() == "customer")
						{
							cryRpt.SetParameterValue("customer", as_cust_pass);
							li_ret = 1;
							break;
						}
					}
				}

				if (!(as_user_pass == null))
				{
					for (int i = 0; i < li_cont; i++)
					{
						if (ls_parmNames[i].ToLower() == "user")
						{
							cryRpt.SetParameterValue("user", as_user_pass);
							li_ret1 = 1;
							break;
						}
					}
				}
				if (li_ret == 0 && li_ret1 == 0)
				{
					//gnv_app.inv_error.of_message("no_parameters_exec_rep")
				}
			}
			else
			{
				//cryRpt.DiscardSavedData;
				bool autoSaveData = cryRpt.ReportOptions.EnableSaveDataWithReport;
				if (!autoSaveData && cryRpt.HasSavedData)
				{
					MessageBox.Show("Discarding unsaved data in the report");
				}
				cryRpt.Refresh(); //&& not sure if this works all correctly for the DiscardSavedData;
				cryRpt.VerifyDatabase(); //&& what is this good for ?
			}
			break;
		}
	
	// show the report
	crystalReportViewer1.ReportSource = cryRpt;
	crystalReportViewer1.Refresh();
}

Hope it might give you any useful information.

regards.

 

Comment
There are no comments made yet.
Falguni Patel Accepted Answer Pending Moderation
  1. Wednesday, 22 September 2021 11:09 AM UTC
  2. PowerBuilder
  3. # 3

Hi Miguel,

 

As per the instructions, I ran batch file and registry entries are added to my develoment PC. However, I could not see this object to insert while using File > Control > New OLE Control.

 

Kindly help.

Kind regards,

Falguni

Comment
  1. Miguel Leeuwe
  2. Monday, 27 September 2021 08:54 AM UTC
Hi Falguni, I'll try to isolate some powerbuilder code that passes in some parameters.

The problem I have, is that the code that I found before migrating from Crystal Reports 8, which had an activex ready for use, is a huge mess. My only first effort was to get the mess working with the new Visual Studio Crystal Reports stuff.

I'll see what I can do, though.

  1. Helpful
  1. Falguni Patel
  2. Monday, 11 October 2021 02:58 AM UTC
Hi Miguel,

I managed to add the parameters to existing code. However, I wish to add about 10+ parameters. Hence, I need to change the c# Open Report function. I modified the function but the OpenReport function with new parameters does not work. However, the same codes work with old OpenReport function with less number of arguments. It seems that the call is made to old function instead of new. Do I need to unregister the Ole function. Your usual assistance will be greatly appreciated.

  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 11 October 2021 12:30 PM UTC
Hi, I’m away for a week and only have a tablet. Most probably you have to unregistered or uninstall when using my old example. I remember the guids for the type lib functions being automatically changed every time you compile. Possibly, the dll is also present in the gac. I made a newer version with interface and I think I managed to prevent the guids from changing every time I compile. Can’t access that code for over a week though, so please be patient.

Regards
  1. Helpful
There are no comments made yet.
Giuseppe moglia Accepted Answer Pending Moderation
  1. Friday, 15 January 2021 10:49 AM UTC
  2. PowerBuilder
  3. # 4
 

Thank you Miguel 

Great job!

Could we change the crystal report query adding some parameters from PB?

Could we change also a Crystal report stored procedure from PB?

Could you provide with an example?

thanks a lot!!

Comment
  1. Giuseppe moglia
  2. Monday, 12 April 2021 07:20 AM UTC
Hi Miguel



following examples by Yakov Verde about working with ocx at runtime:

https://community.appeon.com/index.php/qna/q-a/develop-with-32-bit-net-dll-and-deploy-application-in-64-bit-in-pb-2019/latest



I found a solution, but I need to create a new registry key after compile your PBL on 64

In attachment the key and the example working for PB2017 R3



https://www.dropbox.com/sh/prj9lnxxi08jlnk/AAD11NWueQZNZxM6dMlSxxYda?dl=0



What do you think?
  1. Helpful 1
  1. Miguel Leeuwe
  2. Thursday, 23 September 2021 12:03 PM UTC
Sorry for the late answer, never saw this. Yes great! I also figured it out. Now CR no longer is an obstacle to build 64 bit executables.
  1. Helpful
  1. Giuseppe moglia
  2. Thursday, 23 September 2021 12:34 PM UTC
Perfect!
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Monday, 2 November 2020 14:25 PM UTC
  2. PowerBuilder
  3. # 5

Hi Miguel, how about making a short tech article that includes all the videos?  I think more people would find it there.

Comment
  1. Miguel Leeuwe
  2. Monday, 2 November 2020 14:29 PM UTC
Hi Armeen,

Yes that's a good idea. However, I haven't completely finished yet.

I will do that when it's a bit more refined.

Cheers!
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Monday, 2 November 2020 15:04 PM UTC
Perfect, thanks for sharing!
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 1 November 2020 22:37 PM UTC
  2. PowerBuilder
  3. # 6

Also, if interested in getting more information on how to wrap a visual .net assembly into an activex, Marco has posted some useful links to some presentation of Bruce Armstrong: https://community.appeon.com/index.php/qna/q-a/use-of-crystalreports-net-dll-in-pb-2019

 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 1 November 2020 18:21 PM UTC
  2. PowerBuilder
  3. # 7

Important: when you click on the video links, please "download" them first if when watching them online from google drive they're too blurry.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.