Quantcast
Channel: SCN : Unanswered Discussions - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 2556

SetParameterValue only working for default value

$
0
0

Greetings, I have created the following external report and C# console application which work perfectly on my development box.

When running the same console app and report on Windows Server 2008 R2 standard, it only works with the default parameter value being passed. It gives an error if I pass anything other than what I originally had set the report with as the default parameter values when running through the preview in the designer.

 

Here's what I created

1. External Crystal report  (.rpt) created in the Stand Alone Report Builder Version 14.0.4.738 RTM not Visual Studio

This report has a datasource with an integrated security to an MS Sql 2008 R2 Sql procedure via connection created through OLE DB (ADO), so no passwords or usernames. The report has 2 parameters. Application on server is using admin credentials to run so has full access to the DB.

 

2. I created a C# console App in VS 2013 that calls this report and sends the parameters to the report for each print job creating a new instance for the report each time since they go to different printers depending on the Branch of ea user. (for testing purposes I've pointed all Branches to my development printer). Visual Studio is using dlls Version 13.0.2000.0

 

3. Results from Windows Server....

Sends the first 2 parameters just fine

param 1 : Route

param 2 : EmpID

 

prints to my dev printer

 

loops back after closing report and creates a second reportdocument

Sends the second set of parameters

param 1 : Route2

param 2 : EmpID2

 

Then Errors out with the following

Error in File "reportname" (###-###).rpt

unable to connect: incorrect log on parameters. ---> System.Runtime.InteropServi....

at CrstalDecisions.ReportAppServer.Controller.ReportSourceClass.Getlast.....

ETC.

 

It does not matter in which order I send the matching default parameters. The default parameter always prints out fine and the other one always fails. Default parameters never error out.

 

 

See pseudo code example below

 

string[,] EmpIDs = getEMPIDs();

foeach EmpID

{

     printreports(EmpID[])

}

 

printreports(EmpID)

{

     string sPrinter = getDefaultPrinter(EmpID);

     ReportDocument rpt = new ReportDocument();

     string sReportPath = System.AppDomain.CurrentDomain.BaseDirectory + @"Crystal\myreport.rpt";

     rpt.Load(sReportPath);

     rpt.SetParameterValue("@Route", Route);

     rpt.SetParameterValue("@EmployeeID", EmpID);

     rpt.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default;

     rpt.PrintOptions.PrinterName = @"" + sPrinter;

     rpt.PrintToPrinter(1, false, 0, 0);

     rpt.Close();

}

 

Again, this all works perfectly fine from my machine, but when on the Windows Server, it only works with the default parameters. I tested this by changing the default parameters on the report and then only those default parameters would work.

 

Much Appreciated.


Viewing all articles
Browse latest Browse all 2556

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>