I am creating rdlc report(not using reportviewer, using report template). I have a business class which has a code for getting dataset by calling stored procedure. I am binding that dataset to rdlc report using ReportDataSource class. How to access this dataset in design?
In rdlc xml file, I tried to add dataset and it fields, it works fine if the columns are constant. I have a dataset it returns a datatable which has variable number of columns depending on user selection, will get to know number of columns at run time, that dataset I want to assign to table or any control in rdlc design. How can I do that?
Thanks,
Megha
Related
I have a framework for my applications that hold reports that are printed from the application. I have one report that I'm trying to add a second dataset to but I keep getting the error "A data source instance has not been supplied for the data source 'DataSetTwo'". Is it impossible to add a second dataset to a report?
The reason I'm adding a second data source is I have one that will populate nearly all information on the report and then the second is going to be used for a tablix in the report. I can't use the first dataset because for some reason the group by is not working on the SQL statement so I'm going to add a new dataset with less fields so the group by isn't a problem.
The error
A data source instance has not been supplied for the data source 'DataSetTwo'
indicate you had not supply the data source.
When you generate the report, did you supply the second dataset?
It should look something like this:
ReportViewer.LocalReport.DataSources.Clear();
ReportDataSource rd1 = new ReportDataSource("DataSetOne", dataset1);
ReportDataSource rd2 = new ReportDataSource("DataSetTwo", dataset2);
ReportViewer.LocalReport.DataSources.Add(rd1);
ReportViewer.LocalReport.DataSources.Add(rd2);
ReportViewer.LocalReport.Refresh();
I have a few DataGridView tables which user fills (I don't use any Dataset or Database here).
I need to pass them to ReportViewer, I want exact the same tables in report as in a form, no changes at all.
I tried something like this, but it's not working:
Dim rds As New ReportDataSource("rds1", Form1.dgv1.DataSource)
Me.ReportViewer1.LocalReport.DataSources.Add(rds)
and in report1.rdlc added a table and set it dataset name to rds1 but it generates error
The table ‘table1’ refers to an invalid DataSetName ‘rds1’.
So I guess I need to make a DataSet from my DataGridView tables.
How would you suggest me to do that? Otherwise, is there any simpler way to pass the table to report?
You should add a DataSet to your report .rldc Data Sources list and drag and drop the columns into your report element (table, tablix, list etc.)
Remember you can add any kind of object from your project to your report as Data Source (basically any Public Class you create). The imported names and types will be taken from the class properties.
I have used 2 sub reports in my crystal report. Both these reports are from separate tables having no connection between them...I have inserted these reports in the details section....I have used dataset to pass source data to these reports...But when i view the report, the sub reports' data isn't filtered according to the dataset rather all the rows are shown in the reports.. How can i get rid of this problem....i just want to view the data like if user wants to view a report for 2011 then it should only show information from the database records having 2011 as the Year part...Can anyone help me on this
The solution to your problem is dependent on how your user specifies the criteria for the report and where in your application they enter that criteria.
For example, if you provide a prompt for the user within your application to get the year for the report, then retrieve the datasource and pass it to crystal, then you should filter the data in the datasource before passing the datasource to crystal. You could also set parameters in crystal to filter the data, but my rule of thumb is to retrieve as little data as necessary to provide the required information.
However, if the user is prompted from within crystal reports for the criteria, then you need to use standard crystal functionality to filter the data. This involves adding record selection formulas using the user entered parameters.
I have 9 tables with state information in them. They all have the same field names. I have a Crystal Report that is based on one of them. I want the user to be able to select a state and change the Crystal Report to use that table instead of the one it was based on.I mean when user select text in combo box and then click on "OK" then report show (using only one rpt for all the tables of same fields).
How do I do that in VB.Net?
Could you base the Report on a Stored Procedure and pass in a parameter so the Stored Procedure knows which table you want the data from?
I remember trying to get a Crystal Report (v2005) to switch database source from the one it was designed against and that wasn't easy - every table had the connection details in it if I recall correctly! (maybe changing tables is easier though)
It's not easier but if the tables have the same structure you should be able to do it. But you should create a new Document for it and call SetDataSource for your new table. After this you can set the document as ReportSource to your viewer.
I want to create a column on a crystal report. I am binding crystal report to .net class object collection at run time. Now one of the columns I need to bind to the object collection property which is another object to it’s property.
How do I do this ?
domain of the qustion is not that cliear.
if the object what you need to display in the report is not in the detail section of the report you will be able to pass this as a parameter.
if this is not not working for you. create the report based on a xml schema. and genarate the report based on that schema.
http://vb.net-informations.com/crystal-report/vb.net_crystal_report_from_xml_file.htm
http://www.codeproject.com/KB/cs/xmlcrreport.aspx