Generate crystal report by passing query string using php

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

monty
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Dec 06, 2012 3:09 am

Generate crystal report by passing query string using php

Postby monty » Thu Dec 06, 2012 8:19 pm

I want to pass query string to crystal report from php.I have created crystal report and can open it by exporting it to pdf in the browser.I have done this by reffering php.net site.The syntax and methods used is like vb.I have tried using SQLQuery method of vb to pass query to crystal report but I am getting error as Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `SQLQuery' in C:\wamp\www\Drainage\crystalrpt.php on line 14.The code which I have used is as follow:

<?php

set_time_limit(0);

$path = "C:\\wamp\\www\\Drainage\\Reports";
$file = "C:\\PartyName.pdf";
$app_obj = new COM("CrystalRuntime.Application") or Die ("Did not open");
$report= $path."\\PartyName.rpt";
com_load_typelib('CrystalDesignRunTime.Application');
$rpt_obj= $app_obj->OpenReport($report,1);

$rpt_obj->Database->Tables(1)->SetLogOnInfo("ServerName","DatabaseName","username","password");

$rpt_obj->SQLQuery = "SELECT PartyMaster.PartyName, PartyMaster.PropertyNo, PartyMaster.ConnectionNo FROM DatabaseName.dbo.PartyMaster Where PartyMaster.ConnectionNo='10916'";//Getting Error on this line

$rpt_obj->EnableParameterPrompting = true;
$rpt_obj->ExportOptions->DiskFileName = $file;
$rpt_obj->ExportOptions->PDFExportAllPages = true;
$rpt_obj->ExportOptions->DestinationType = 1;
$rpt_obj->ExportOptions->FormatType = 31;
$rpt_obj->Export(false);

$rpt_obj = NULL;
$app_obj = NULL;

header("Content-Type: application/pdf");
readfile($file);
unlink($file);
?>

If I comment the errored line I get default report but I want to use query string to get report.Just want to know is there ant other method to pass query string to crystal report.Any help in this matter would be appreciated. :? :help:

User avatar
webinfopedia
New php-forum User
New php-forum User
Posts: 84
Joined: Sat May 21, 2011 10:26 pm
Contact:

Re: Generate crystal report by passing query string using ph

Postby webinfopedia » Fri Dec 14, 2012 2:53 am

Hi
You can use excel to generate your report. I have posted an article regarding that..

http://www.webinfopedia.com/export-database-data-to-excel-in-php.html

Hope that this will help you..

Thank You
webinfopedia

monty
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Dec 06, 2012 3:09 am

Re: Generate crystal report by passing query string using ph

Postby monty » Fri Dec 14, 2012 9:14 pm

Thank You for your reply but I already have reports developed in Crystal report and I want to use the same for the project.Previously the project was developed in classic ASP and now I have converted it to php.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron