In my rdlc report I create parameter test. In form I write below code to set parameter:
//Set Parameters
ReportParameter[] p = new ReportParameter[1];
p[0] = new ReportParameter("Test", "Testing");
currentBilling_rv.LocalReport.SetParameters(p);
// Provide datasource to report Current_Total_Billing.rdlc
ReportDataSource rds = new ReportDataSource("CurrentTotalBilling", dataset.Tables[2]);
currentTotalBilling_rv.LocalReport.DataSources.Clear();
currentTotalBilling_rv.LocalReport.DisplayName = "Current Total Billing";
currentTotalBilling_rv.LocalReport.ReportPath = ".\\Current_Total_Billing.rdlc";
currentTotalBilling_rv.LocalReport.DataSources.Add(rds);
currentTotalBilling_rv.RefreshReport();
When I run the program I have exception
An unhandled exception of type
'Microsoft.Reporting.WinForms.MissingReportSourceException' occurred
in Microsoft.ReportViewer.WinForms.dll
Additional information: The source of the report definition has not
been specified
Please help.
In your code you are setting a parameter for a ReportViewer named currentBilling_rv not for currentTotalBilling_rv which is used in the next lines of code.
If currentBilling_rv name is correct verify that currentBilling_rv.LocalReport.ReportPath is compiled.
Related
My question is about the ReportViewer control of devexpress 12 in visual studio 2012 that does not recognize the LocalReport property, I am using Visual Studio 2012 and Devexpress.
using Microsoft.Reporting.WebForms,
and it gives me error
ReportParameter[] parameters = new ReportParameter[2];
parameters[0] = new ReportParameter("tipo_empresa", ASPxComboBox_Tipo_Empresa.Text);
parameters[1] = new ReportParameter("empresa", ASPxComboBox_Empresa.Text);
// RepViewerAccident.LocalReport.SetParameters(parameters);
Error logs:
DevExpress.XtraReports.Web.ReportViewer 'does not contain a definition of' LocalReport 'nor was any extension method' LocalReport 'that accepts a first argument of type' DevExpress.XtraReports.Web.ReportViewer 'found (missing a usage directive or an assembly reference?)
I suggest you go through Use Report Parameters documentation and you can Request and Pass Report Parameter Values
using DevExpress.XtraReports.Web;
//...
protected void Page_Load(object sender, EventArgs e) {
XtraReport1 report = new XtraReport1();
report.Parameters["parameter1"].Value = Convert.ToInt32(Request.QueryString["parameter1"]);
ASPxWebDocumentViewer1.OpenReport(new CachedReportSourceWeb(report));
}
You can also create your custom report parameters - Create Custom Report Parameters
using DevExpress.XtraReports.Parameters;
using DevExpress.XtraReports.UI;
// ...
public enum Gender { Male, Female }
// Create a report instance.
XtraReport report = new XtraReport();
// Create a new parameter.
Parameter param = new Parameter();
// Specify required properties.
param.Name = "GenderParameter";
param.Type = typeof(Gender);
param.Visible = true;
//Add the parameter to the report.
report.Parameters.Add(param);
I'm having an issue with my report giving an error when I try to pass it a parameter value that I get from the query string.
With the current settings below I am getting the following error: "An error has occurred during report processing.
Failed to evaluate the FilterValue of the Tablix ‘Tablix2’"
In my designer I have a table with columns dragged from the dataset.
I have a textbox and the label is the parameter CHAPTER_ID. It shows up as "#Error". Both when I set it as integer or Text
The table populates fine, but cannot filter using the parameter. I can Hardcode a value and it filters.
ASPX
<rsweb:ReportViewer ID="ReportViewerAnyReport" runat="server" Height="800px" ProcessingMode="Local"
Style="position: relative" Width="1100px"></rsweb:ReportViewer>
ASPX.CS
protected void Page_Load(object sender, EventArgs e)
{
if (!(Page.IsPostBack))
{
List<GetComments_Result> comments = RexCommentBAO.GetAllComments();
string s_chapterId = Request.QueryString["ChapterID"];
try
{
ReportDataSource datasource = new ReportDataSource("ds_comments", comments);
ReportViewerAnyReport.LocalReport.DataSources.Add(datasource);
ReportViewerAnyReport.LocalReport.ReportEmbeddedResource = #"C:\Work\W2R.Rex\Rex\Rex\Rex_Web\RexReports.rdlc";
ReportViewerAnyReport.LocalReport.ReportPath = #"C:\Work\W2R.Rex\Rex\Rex\Rex_Web\RexReports.rdlc";
ReportParameter p = new ReportParameter("CHAPTER_ID", s_chapterId);
this.ReportViewerAnyReport.LocalReport.SetParameters(new ReportParameter[] { p });
ReportViewerAnyReport.LocalReport.Refresh();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
In my rdlc [Design] --
Parameters Properties
General Tab:
Name: CHAPTER_ID
Data type: Text (Tried Integer - codebehind passes string. Integer throws the error: "An error has occurred during report processing. Failed to evaluate the FilterValue of the Tablix ‘Tablix2’".
Checkboxes (all unchecked)
-Allow Blank value("")
-Allow null value
-Allow multiple values
Available Values Tab: None is selected
Default Values Tab: None is selected
Tablix properties:
General Tab:
Dataset name: ds_comments
Filters Tab:
Expression: Fields!CHAPTER_ID.Value Text (Tried Integer)
Operator: =
Value: [#CHAPTER_ID] - the expression for this value is "=Parameters!CHAPTER_ID.Value". Hard coded a value and it filtered the data.
So it appears that you can't use Parameters when doing LocalReport. Changed it by passing in the datasource pre filtered.
List<CMT> comments = RexCommentBAO.GetCommentsByChapterId(i_chapterId);
I have created a report in my C# ASP.net web application, to generate a cover page of a proposal. I am attempting to pass the proposal ID to the report. My dataset is set up to accept the proposal ID as a query parameter, and I have the GetByProposalID and FillByProposalID methods defined.
The problem is that when the report runs, the report viewer does not contain data. Either the problem is in my code, or in my report / report viewer configuration.
Here's my method:
/// <summary>
/// Generate the cover page report as a PDF file from a given proposal
/// </summary>
/// <param name="ProposalID">Proposal ID from the database of the proposal</param>
public void GenerateCoverPage( int ProposalID )
{
ReportViewer viewer = new ReportViewer();
viewer.Reset();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "ReportCoverPage.rdlc"; //sets the report from the project RDLC file
//Connect the dataset to the report
ds_ReportCoverPage ds = new ds_ReportCoverPage();
ds_ReportCoverPage.dt_ReportCoverPageDataTable table = new ds_ReportCoverPage.dt_ReportCoverPageDataTable();
ds_ReportCoverPageTableAdapters.dt_ReportCoverPageTableAdapter ta = new ds_ReportCoverPageTableAdapters.dt_ReportCoverPageTableAdapter();
ta.FillByProposalID(table, ProposalID); //This SHOULD fill the adapter with the data from the selected proposal
ReportDataSource source = new ReportDataSource("ds_Report_ReportCoverPage", ds.Tables[0]); //Name must match the data source name within the report
viewer.LocalReport.DataSources.Add(source);
//Run-time exception that there is no report parameter "#Proposal"
//ReportParameter parm = new ReportParameter("#Proposal", ProposalID.ToString()); //Placeholder in report query
//viewer.LocalReport.SetParameters(parm);
viewer.LocalReport.Refresh();
string filepath = "C:\\Temp\\foo.pdf";
SavePDF(viewer, filepath);
}
As you can see, I tried to pass the parameter as a ReportParameter, but the parameter is in the query and not the report so it was rejected.
(I've gotten this far thanks to looking up other questions on SO.)
You will need a parameter in the report and then you can map that parameter to the parameter in the query in the data set.
I am trying to use crystal report with asp mvc first time but I have some problem to load report:
ReportClass rptH = new ReportClass();
rptH.FileName = Server.MapPath("Reports/TestReport.rpt");
rptH.Load();
This is value of rptH.FileName
"rassdk://D:\\ProjectDir\\Pro\\Pro.WebUI\\Reports\\TestReport.rpt"
But on Load() I get exception:
Load report failed.
Report doesn't have any datasource it's just blank report with some text.
Maybe it's important. I set project to run on local IIS (not in VS).
UPDATE
I have changed code a little bit and now I get some other error (I also copied project in inetpub/wwwroot). This is the error:
Value cannot be null. Parameter name: path2
And path now is:
"C:\\inetpub\\wwwroot\\MyProject\\Pro\\Pro.WebUI\\Reports\\TestReport.rpt"
New code is:
ReportClass rptH = new ReportClass();
var path = Server.MapPath("Reports/TestReport.rpt");
rptH.Load(path);
I've done a Crystal Report with ASP.NET before. Not sure if you're able to do this or not, but it worked successfully for me.
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("TestReport.rpt");
Response.Buffer = False
Response.ClearContent()
Response.ClearHeaders()
rptDoc.ExportToDisk(ExportFormatType.PortableDocFormat, "TestReport.rpt")
rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "MyReport")
Check the rpt file if there are parameters defined.
If there are and you do not need them then remove it.
If you need them then supply them values and description in code.
Exp:
rep = new ReportDocument();
string reportPath = Server.MapPath("Reports/TestReport.rpt");
rep.Load(reportPath);
rep.SetParameterValue(0, "SomeValue");
crViewer.ReportSource = rep;
crViewer.ParameterFieldInfo[0].CurrentValues[0].Description = "ParameterName";
crViewer.DataBind();
Try this
ReportDocument rd = new ReportDocument();
string FileName = Server.MapPath("~/Report") + "//YourReportName.rpt";
rd.Load(FileName);
rd.SetDataSource(dt);
i have business object called "TeamMaster",
in which i define three properties,Id,Name & Flg.
in my .rdlc report i apply TeamMaster object as a data source,
now i write the following code in page load event of form in which i add report viewer control and i define my report as a local report.
using (RDLC_DEMO_DBEntities objdatabase = new RDLC_DEMO_DBEntities())
{
lstTeamMstr = objdatabase.TeamMasters.ToList();
}
this.TeamMasterBindingSource.DataSource = lstTeamMstr;
this.reportViewer1.RefreshReport();
when i check this code using debugging i get 6 records in TeamBindingSource,
but in windows report only displays six blank rows,
what is the problem?
Follow this code : >>
string path = HttpContext.Current.Server.MapPath(Your Report path);
ReportViewer1.Reset(); //important
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
// Add sub report even handler if you need
***ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(MySubreportProcessingEventHandler);***
LocalReport objReport = ReportViewer1.LocalReport;
objReport.ReportPath = path;
// Add Parameter If you need
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("Name", Value));
ReportViewer1.LocalReport.SetParameters(parameters);
ReportViewer1.ShowParameterPrompts = false;
ReportViewer1.ShowPromptAreaButton = false;
ReportViewer1.LocalReport.Refresh();
//Add Datasourdce
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "Datasource Name Used due to report design";
reportDataSource.Value = DataSourceValue(Your object data-source);
objReport.DataSources.Add(reportDataSource);
objReport.Refresh();
Here Subreport Even handler code
private void MySubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
//You can get parameter from main report
int paramname = int.Parse(e.Parameters[0].Values[0].ToString());
//You can also add parameter in sub report if you need like main report
//Now add sub report data source
e.DataSources.Add(new ReportDataSource("DataSource Name",DataSourceValue)));
}
If you need to create Drillthrough report than follow this link Click here for Drillthrough report