Page 1 of 1

Viewer.php and Stored Procedure parameters

Posted: Sun Dec 09, 2018 9:39 am
by jkrassman
Hi,

I am designing my report and it just works fine in the designer with the parameters. Then when I "Publish" my project and all the files are done, it seems to be missing the code to handle my paramaters?

This is the index.php file

Code: Select all

<?php
require_once "stimulsoft/helper.php";
?>
<!DOCTYPE html>

<html>
<head>
	<title>Report.mrt - Viewer</title>
	<link rel="stylesheet" type="text/css" href="css/stimulsoft.viewer.office2013.whiteblue.css">
	<script type="text/javascript" src="scripts/stimulsoft.reports.js"></script>
	<script type="text/javascript" src="scripts/stimulsoft.viewer.js"></script>

	<?php
		$options = StiHelper::createOptions();
		$options->handler = "handler.php";
		$options->timeout = 30;
		StiHelper::initialize($options);
	?>
	<script type="text/javascript">
		function Start() {
			Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("localization/sv.xml", true);

			var str = Stimulsoft.System.IO.File.getFile("reports/Report.mrt");
			var report = new Stimulsoft.Report.StiReport();
			report.load(str);

			var options = new Stimulsoft.Viewer.StiViewerOptions();
			var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);

			viewer.onBeginProcessData = function (args, callback) {
				<?php StiHelper::createHandler(); ?>
			}

			viewer.report = report;
			viewer.renderHtml("viewerContent");
		}
	</script>
</head>
<body onload="Start()">
	<div id="viewerContent"></div>
</body>
</html>
And this is the handler.php

Code: Select all

<?php
require_once "stimulsoft/helper.php";

// Please configure the security level as you required.
// By default is to allow any requests from any domains.
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Engaged-Auth-Token");

$handler = new StiHandler();
$handler->registerErrorHandlers();

$handler->onBeginProcessData = function ($args) {
	return StiResult::success();
};

$handler->process();
Where and how should i provide my parameter @corpid?

Regards, Joakim

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 7:09 am
by Lech Kulikowski
Hello,

In the JS version, parameters are not supported. You can use variables instead of parameters in your query:
select * from Table where column = {Variable}

and then provide values for variables.

Thank you.

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 7:23 am
by jkrassman
Ok, but I am using stored procedures for a lot of my queries?

If i use the PHP version, will that support parameters?

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 7:25 am
by Lech Kulikowski
Hello,

Unfortunately, no. Only variables.

Thank you.

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 7:32 am
by jkrassman
Ok, so there is no solution to grab a stored procedure with a parameter to create a webreport?

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 7:34 am
by Lech Kulikowski
Hello,

You can use Variables in the query:
exec StoreProcName {Variable1}, {Variable2} ...

Thank you.

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 7:37 am
by jkrassman
I am using temp tables in my procedures and getting this error:

"Invalid object name '#tmp'."

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 8:02 am
by jkrassman
Found the solution, had to add:

IF 1=0 BEGIN
SET FMTONLY OFF
END

To my procs.

Re: Viewer.php and Stored Procedure parameters

Posted: Mon Dec 10, 2018 1:46 pm
by Lech Kulikowski
Hello,

Thank you for the information.