Dealy

Dealy

  • NA
  • 213
  • 0

Loading Crystal Report with parameters - ASP.NET Web forms

Jun 21 2016 2:31 AM
Hello,
 
I'm trying to load a crystal reports with parameters using a stored procedure as a data source.I'm using Visual Studio 2015 with ASP.NET Web forms.
 
I've created the report (Report1.rpt) using wizard, binding it on my stored procedure. When I was asked to enter the parameters I left it blank.
 
Here's my code:
  1. protected void Button1_Click(object sender, EventArgs e)  
  2.         {  
  3.              ReportDocument reportDocument = new ReportDocument();  
  4.              ParameterField paramField = new ParameterField();  
  5.              ParameterFields paramFields = new ParameterFields();  
  6.              ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();  
  7.   
  8.              paramField.Name = "@id";  
  9.              paramDiscreteValue.Value = "123";  
  10.              paramField.CurrentValues.Add(paramDiscreteValue);  
  11.              paramFields.Add(paramField);  
  12.   
  13.              paramFields.Add(paramField);  
  14.   
  15.              CrystalReportViewer1.ParameterFieldInfo = paramFields;  
  16.   
  17.              string reportPath = Server.MapPath("~/User/Report1.rpt");  
  18.   
  19.             reportDocument.SetDatabaseLogon("user""pass","SERVER""DB1"false);  
  20.   
  21.             reportDocument.Load(reportPath);  
  22.   
  23.              CrystalReportViewer1.ReportSource = reportDocument;  
 1. When I click on the button I get nothing. Any ideas why the report is not loading?
 
 2. If i use the following code I get error in "SERVER\TSQL2012"
  1. reportDocument.SetDatabaseLogon("user""pass","SERVER\TSQL2012""DB1"false);  
 
Any kind of help would be appreciated!
 
Thank you in advance. 
 
 

Answers (4)